【发布时间】:2018-09-19 16:06:14
【问题描述】:
我正在使用 com.google.appengine.api.memcache.MemcacheService 与 Google Memcache 合作。
存储值时,我设置了 60 秒的过期时间。但是即使在几分钟后,该值仍会从缓存中返回。
使用 Memcache 的代码:
// Config
int expirationSeconds = 60;
Expiration expiration = Expiration.byDeltaSeconds(expirationSeconds);
MemcacheService memcache = MemcacheServiceFactory.getMemcacheService();
// Write operation
memcache.put(id, value, expiration);
// Read operation
memcache.get(id);
我预计在这种情况下该值不存在,因为 Memcache documentation 表示 An expired item is removed when someone unsuccessfully tries to retrieve it。
为什么仍然从 Memcache 返回过期值?
【问题讨论】:
-
你是如何配置 Memcache 的?请分享相关代码的sn-p。
-
@Dmitry Grankin 我刚刚测试了您提供的代码,对我来说一切正常(内存缓存中没有值并且返回 null)。你还在遇到这个问题吗?
标签: java google-app-engine memcached