0
votes

i have upgraded to appengine sdk 1.8.0, appengine DN 2.1.2 and DN 3.1.3. all working nice.

in the appengine docs it states

Level2 Caching is enabled by default. 

https://developers.google.com/appengine/docs/java/datastore/jpa/overview-dn2

I assume that the JPA L2 cache is backed by memcache.

but when i update the entity by Datastore viewer the JPA code is still returning the stale version of data.

my JPA entity is below

@Entity
@Cacheable(true)
@NamedQueries({ ....snip

public class GeoLocationUser implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Key key;

private double latitude;

the query is a named query

@NamedQuery(name = GeoLocationUser.FIND_BY_USER_KEY,
            query = "Select p from GeoLocationUser p where p.parentKey = :userKey"),

use case

  1. Entity is created using JPA code.

  2. I update a field called 'latitude' in the entity using datastore viewer from '0.0' to '1.0'.

  3. i run a restful query on my application using JPA.

  4. the entity returned has 'latitude' = '0.0'

  5. i then flush memcache

  6. i run a restful query on my application using JPA.

  7. the entity returned has 'latitude' = '0.0'

the JPA code is picking up the stale data and i dont know why.

Q1.any explanation on the observed behaviour i most appreciated.

Q2. is the appengine DN 2.1.2 backed by memcache?

thanks -lp

1
look in the log if you want to know what is happening. I wouldn't assume anything about caching and the user is the one who defines what is used. - DataNucleus

1 Answers

1
votes

from the logs it seems that indeed level 2 cache 'soft' is the default. no idea exactly sure what the 'soft'means.

however it seems that level 1 cache is causing the behaviour above.

when i stopped the running instance the next invocation caused a new instance with a new level 1 cache. then the new value is returned.

very impressive caching guys. well done.

-lp