Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8398007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:55:35+00:00 2026-06-09T20:55:35+00:00

I use simple layer for loading and storing entities by key or id and

  • 0

I use simple layer for loading and storing entities by key or id and I just added caching to this layer. When entity with given key is in the cache, return it rather then fetch from the datastore. And when the entity is updated and saved to datastore, the layer simply sets the entity in the cache to null. It’s completely transparent.

It seems to be working fine, however the object fetched from the cache is slightly different from the object fetched from the datastore. Some things stopped working, for example and I can’t use .contains() on Collections inside entity to check whether there is a relationship between two entities. I also encountered a weird behavior, when I loaded an object from cache and immediately after that stored to the datastore, all items in collections representing relationships were replaced with nulls. However I couldn’t reproduce it. Now it’s working fine.

I don’t know what’s happening under the hood, so the question is, is this way of working with cache reliable? Can I work with entities fetched from cache just like as they were fetched from the datastore (accessing children, updating, removing…)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:55:36+00:00Added an answer on June 9, 2026 at 8:55 pm

    Two things to note:

    1. All objects stored to Memcache get serialized/deserialized, meaning their memory representation is taken and changed into a series of bytes (and vice versa).

    2. Collection.contains(object) uses object.equals(anotherObject) to check if collection contains certain object. By default Object.equals() is only true if this is the exact same object (= object at the same memory location).

    Given that: serializing object and then deserializing it will never make an object that gives deserialisedObject.equals(originalObject) == true.

    If you really need this, than you should override .equals() (and also .hashCode()) in the class you store in Memcache, so that you actually compare meaningful values inside the Class (= compare values of all fields).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We often use simple enumerations to represent a state on our entities. The problem
How to use simple TCP/IP sockets connections over/with Net.TCP WCF binding? Idea is –
I'm trying to use Simple Savant within my application, to use SimpleDB I currently
Is there a way to use simple sql queries on ASP MVC without using
I've always thought it was great that I could use simple iconic unicode characters
I've used ITK with c++ some time ago and I'm trying to use simple
use LWP::Simple; use Parallel::ForkManager; @links=( [http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-windows.exe,SweetHome3D-2.1-windows.exe], [http://prdownloads.sourceforge.net/sweethome3d/SweetHome3D-2.1-macosx.dmg,SweetHome3D-2.1-macosx.dmg], [http://prdownloads.sourceforge.net/sweethome3d/SweetHome3DViewer-2.1.zip,SweetHome3DViewer-2.1.zip], ); # Max 30 processes for
I use a simple pipe. I read with a while, 1 char at a
OK, this is basically just about any non-default OS API running on all different
I'm writing a simple templating layer in PHP but I've got myself a little

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.