【问题标题】:appengine DataNucleus plugin 2.1.2 cache behaviourappengine DataNucleus 插件 2.1.2 缓存行为
【发布时间】:2013-05-22 08:42:24
【问题描述】:

我已升级到 appengine sdk 1.8.0、appengine DN 2.1.2 和 DN 3.1.3。 一切正常。

在它声明的 appengine 文档中

Level2 Caching is enabled by default. 

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

我假设 JPA L2 缓存由 memcache 支持。

但是当我通过 Datastore 查看器更新实体时,JPA 代码仍然返回过时的数据版本。

我的 JPA 实体在下面

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

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

private double latitude;

查询是命名查询

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

用例

  1. 使用 JPA 代码创建实体。

  2. 我使用数据存储查看器将实体中名为“纬度”的字段从“0.0”更新为“1.0”。

  3. 我使用 JPA 在我的应用程序上运行了一个安静的查询。

  4. 返回的实体有 'latitude' = '0.0'

  5. 然后刷新内存缓存

  6. 我使用 JPA 在我的应用程序上运行了一个安静的查询。

  7. 返回的实体有 'latitude' = '0.0'

JPA 代码正在获取过时的数据,我不知道为什么。

Q1.我最欣赏对观察到的行为的任何解释。

第二季度。 appengine DN 2.1.2 是否由 memcache 支持?

谢谢 -lp

【问题讨论】:

  • 如果您想知道发生了什么,请查看日志。我不会假设任何关于缓存的事情,并且用户是定义使用什么的人。

标签: google-app-engine datanucleus


【解决方案1】:

从日志看来,2 级缓存“软”确实是默认设置。 不知道“软”是什么意思。

但似乎是 1 级缓存导致了上述行为。

当我停止正在运行的实例时,下一次调用会导致一个具有新 1 级缓存的新实例。然后返回新值。

非常令人印象深刻的缓存家伙。 做得好。

-lp

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-07-01
    • 1970-01-01
    • 2012-07-22
    • 2013-08-03
    • 1970-01-01
    • 2012-05-13
    • 2013-07-02
    • 2019-05-15
    相关资源
    最近更新 更多