gpt4 book ai didi

java - 通过缓存加速重复操作

转载 作者:太空宇宙 更新时间:2023-11-04 08:05:02 25 4
gpt4 key购买 nike

缓存如何与 App Engine 配合使用?只需添加 @Cached 注释就足够了:

@Cached
public class MyEntity {
@Id Long id;
...
}

但是,来自 Objectify 文档:

“v3.1 之前的 Objectify 全局缓存支持因争用而出现同步问题。请勿将其用于需要事务完整性的实体,并且强烈建议您对所有缓存值应用过期期限。”

这是否意味着如果我有一个具有下面这种形式的代码,我不应该使用它?

DAOT.repeatInTransaction(new Transactable() {
@Override
public void run(DAOT daot)
{
Counter count = daot.ofy().find(Counter.class, COUNTER_ID);
count.increment();
daot.ofy().put(count);
}
});

最佳答案

Objectify 尽最大努力提供全局缓存支持 as transactional as possible :

The cache in 3.1 has been rewritten from scratch to provide near-transactional consistency with the datastore.

例如,如果您的请求或任务正好达到截止日期限制,则有可能 a write could make it to the datastore but not update the cache :

The cache is near-transactional. Under normal operation, the cache will not go out of sync with the datastore, even under heavy contention. The exception to this is DeadlineExceededException at the 30s (10m for tasks) hard deadline. If Google kills your process before the cache update occurs, there's nothing we can do.

关于java - 通过缓存加速重复操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12212541/

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