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 7871681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:58:42+00:00 2026-06-03T01:58:42+00:00

This is a very general question regarding GAE / Java Memcache : I have

  • 0

This is a very general question regarding GAE / Java Memcache :

I have an object called Network which is stored in the Memcache , and I have another object called User which has a reference to Network .

Network network=Memcache.get(networkKey);
user._network=network;    //user references an object that came from Memcache...

now I have a bunch of code that changes user._network(without touching Memcache) :

user._network= // do some changes to the objects , without touching Memcache

Ok so here’s the question ,
Looking at the code as it is , did the last line update the network object in the memcache? I have servlets that need to access the updated network object , the question is if I’m wrong by thinking at Memcache objects as regular objects .

Perhaps the right way is this ?

Network network=Memcache.get(networkKey);
network.doUpdate();
Memcache.put(key,network);
  • 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-03T01:58:43+00:00Added an answer on June 3, 2026 at 1:58 am

    The latter code example you provided is the correct way to update the network object in memcache, but I it will work differently than the way you expect.

    Your user object refers to an instance of the network object that has been retrieved from memcache. Each time you retrieve the object from memcache you will get a different instance. And, because the instances are logically distinct from the original within the cache, as soon as the cached value is updated, those instances will become out of sync with the cached version.

    For example:

    Network network=Memcache.get(networkKey);
    Network networkTwo = Memcache.get(networkKey);
    user._network=network;
    networkTwo.doUpdate();
    // network and networkTwo are now different
    Memcache.put(networkKey,networkTwo);
    // user._network still refers to the initial instance of network, not networkTwo
    

    You’ll need additional logic in your code if you want your User objects to always refer to the version of network that is in memcache.

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

Sidebar

Related Questions

All, I have a very general question regarding a future project. I need to
This is a very general question, and I think my context does not matter
This is a very general question: I was wondering whether it is possible to
I have a general question regarding bundles, libraries and custom frameworks on the iOS.
Although this is a very general question, here's my specific example so you can
Just a very general question, that not only applies to this example. Let's say
This is a very general question, so I won't be providing any code as
I have a very general question and have prepared a simple test case. When
I know this is a very general and vague question but I am curious
I asked a related but very general question earlier (see especially this response ).

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.