java - Google App Engine 嵌入式实体似乎从缓存中消失

标签 java google-app-engine memcached

我使用 java memcache api 来存储与用户关联的非持久数据。每个用户都有关联的 memcache 实体来存储一些属性,其中一些属性是嵌入实体。一段时间后,它们消失,而其他属性(字符串、整数、 boolean 值)仍然存在。是有意如此还是我在代码中遗漏了某些内容?我可以依赖缓存中存储至少一个小时或类似的实体吗?我在使用谷歌插件在本地计算机上调试时看到了这种行为。我的代码是这样的:

class UserData {
    public Entity getEntity() {
        Entity ret = new Entity( "User", key );
        ret.setProperty( "property1", _integerval );
        ret.setProperty( "property2", _stringval );
        ret.setProperty( "property3", _complex.getEmbEntity() );
        return ret;
    }

    public static UserData fromEntity( Entity ent ) {
        UserData ret = new UserData();
        ret._integerval = (Integer)ent.getProperty("property1");
        ret._stringval = (String)ent.getProperty("property2");
        ret._complex.fromEmbEntity( (EmbeddedEntity)ent.getProperty("property3") );
        return ret;
    }
}

最佳答案

请记住,Google 的实现并不能保证任何实体都会存在。任何东西都可以在任何时候被驱逐。来自文档:

However, when considering whether to store a value solely in the memcache and not backed by other persistent storage, be sure that your application behaves acceptably when the value is suddenly not available. Values can expire from the memcache at any time, and may be expired prior to the expiration deadline set for the value.

关于java - Google App Engine 嵌入式实体似乎从缓存中消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15239699/

相关文章:

ubuntu - 增加 Memcached 最大项目大小

python - 如何使用 Python(和 boto)通过浏览器将文件复制到 Amazon S3?

google-app-engine - NetBeans 7 上的 Google App Engine

mysql - 同步 mysql 和 memcached/membase

java - Gwt 连接器的单击事件

java - SAX 解析器异常

java - ImageMagick/IM4J FileNotFoundException

java - 将 ResourceInfo 与 mockito 结合使用的单元测试 ContainerRequestFilter

java - 将数据写入App Engine项目中的离线数据存储,然后导出

PHP memcached session 突然过期