gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 23:58:41 25 4
gpt4 key购买 nike

我使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com