Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evict objects from Objectify cache #227

Open
stickfigure opened this issue Apr 9, 2015 · 1 comment
Open

Evict objects from Objectify cache #227

stickfigure opened this issue Apr 9, 2015 · 1 comment

Comments

@stickfigure
Copy link
Contributor

Original issue 213 created by objectify on 2014-07-01T05:18:28.000Z:

What steps will reproduce the problem?

  1. persist object through datastore
  2. read it through Objectify, you get an old version
  3. no way to ask objectify to evict the object from memory

What is the expected output? What do you see instead?
Expecting an api to notify objectify that the object is out of date

What version of the product are you using? On what operating system?
4.0, on gae

Please provide any additional information below.

I'm persisting my objects through this code pattern

Entity filled = ofy().save().toEntity(myPojo);
filled.setUnindexedProperty( "myStuff", "computedSpecialValue" );
datastore.persist(filled);

Reading back my objects, I noticed they are get from cache since Objectify was not notified that it should evict the updated entity from its cache.

I like the Objectify cache feature since it saves me the time to grab data from memcache and reconstuct the objects for each read, so I want my objects to be cached, but I want to be able to evict them.

This discussion says there was no solution in mid 2013, https://groups.google.com/forum/#!msg/objectify-appengine/n3FJjnYVVsk/6Xp99zReOKQJ

If it's still the case, I'd expect an API like

ofy().save().entity(myPojo).evict();

and by the way, I imagine the API would be more consistent if

Entity filled = ofy().save().toEntity(myPojo);

was replaced by

Entity filled = ofy().save().entity(myPojo).toEntity();

Naturally, there's a costly workaround to the issue:

  • save the entity twice (once manually, then through objectify)

a copy of this was posted @ http://stackoverflow.com/questions/24502877/evict-objects-from-objectify-cache

@stickfigure
Copy link
Contributor Author

Comment #1 originally posted by objectify on 2014-07-01T06:15:36.000Z:

As mentioned in the stackoverflow answer, you can workaround this immediately by directly deleting the cache entry from memcache. It's in the namespace ObjectifyFactory.MEMCACHE_NAMESPACE and the cache key is just the stringified (toWebSafeString()) version of the entity key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant