【发布时间】:2011-12-19 22:35:13
【问题描述】:
我在 AppEngine 中使用 memcache 会话处理。有时在发布时,我会以一种使内存缓存内容过时的方式更改对象。当我这样做并进行测试时,我希望能够清除我的会话。
我添加了一个 servlet 来清除使用的内存缓存:
try {
CacheFactory cacheFactory = CacheManager.getInstance()
.getCacheFactory();
cacheFactory.createCache(Collections.emptyMap()).clear();
outputMessage(response, "CLEARED cache");
} catch (CacheException e1) {
LOG.log(Level.SEVERE, "cache issue", e1);
outputMessage(response, "cache issue!!!!!!!!");
}
然后我使用以下方法转储会话内容:
Enumeration<String> e = request.getSession().getAttributeNames();
outputMessage(response, "DUMPING SESSION..");
while (e.hasMoreElements()) {
String name = e.nextElement();
outputMessage(response, "Name:" + name + " value: "
+ request.getSession().getAttribute(name).toString());
}
在清除之前和之后进行会话转储看起来没有任何不同。
我用对了吗?
干杯
【问题讨论】:
-
“清除会话”是什么意思? Memcache 不同于会话。
-
你是如何倾销价值的?请给我们看一些代码。
-
感谢反馈,更新问题
标签: java google-app-engine servlets memcached