请教jive中的缓存保存在HashMap的问题.
我在看到com.jivesoftware.util;包下的Cache类.
里有这样了头两个变量.
protected static long currentTime = CacheTimer.currentTime;
protected HashMap cachedObjectsHash;
为何这个HashMap不用static 变量呢,
但如果不用static,在读取缓存时又怎么定位到这里取缓存的数据呢?
比如说下面先取缓存里的数据:
public DbForumThread get(long threadID)
throws ForumThreadNotFoundException
{
if (!isEnabled()) {
return new DbForumThread(threadID, factory);
}
//Cache is enabled.
DbForumThread thread = (DbForumThread)cache.get(threadID);
if (thread == null) {
thread = new DbForumThread(threadID, factory);
cache.add(threadID, thread);
}
return thread;
}
从上面的方法里看到cache是怎么定位到是原来创建的那个保存的对像呢.
如果说HashMap不用全局static ,那么至少在系统里应有个cache对像是全局的吧.不然的话,应该是取不到缓存的数据才对吧??
但实现看不出在那个地方有创建唯一的.请帮忙解释一下,谢谢