关于Jive论坛中CACHE机制的一个疑问
ThreadMode1.jsp:
ForumThread thread = forum.getThread(threadID);
...
DBForumFactory.java:
DbForumThread thread = cacheManager.threadCache.get(threadID);
ForumThreadCache.java:
DbForumThread thread = (DbForumThread)cache.get(threadID);
LongCache.Java:
LongCacheObject cacheObject = (LongCacheObject)cachedObjectsHash.get(key);
public final Object get(long key) {
int i = indexOfKey(key); //问题在这里,按照HASH算法,有可能是多个thread id(key)对应一个hash值i的
//If not in the map return null
if (i<0) {
return null;
}
else {
return values[i];//而这里直接返回了一个i的object,怎么能保证这个object就是唯一的呢?不会是每次遇到重复的hash值就把上次的覆盖掉吧??如果覆盖了怎么保证读取的ThreadID是唯一的,请高手指点指点
}
}
ThreadMode1.jsp:
ForumThread thread = forum.getThread(threadID);
...
DBForumFactory.java:
DbForumThread thread = cacheManager.threadCache.get(threadID);
ForumThreadCache.java:
DbForumThread thread = (DbForumThread)cache.get(threadID);
LongCache.Java:
LongCacheObject cacheObject = (LongCacheObject)cachedObjectsHash.get(key);
public final Object get(long key) {
int i = indexOfKey(key); //问题在这里,按照HASH算法,有可能是多个thread id(key)对应一个hash值i的
//If not in the map return null
if (i<0) {
return null;
}
else {
return values[i];//而这里直接返回了一个i的object,怎么能保证这个object就是唯一的呢?不会是每次遇到重复的hash值就把上次的覆盖掉吧??如果覆盖了怎么保证读取的ThreadID是唯一的,请高手指点指点
}
}