首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

ehcache2.5的源码分析 - 缓存失效机制

2012-09-15 
ehcache2.5的源码分析 ---- 缓存失效机制2.5的算法变了,清超出的缓存的代码在这里:net.sf.ehcache.store.c

ehcache2.5的源码分析 ---- 缓存失效机制
2.5的算法变了,清超出的缓存的代码在这里:

net.sf.ehcache.store.chm.SelectableConcurrentHashMap
第五百行

int runs = Math.min(MAX_EVICTION, SelectableConcurrentHashMap.this.quickSize() - (int) SelectableConcurrentHashMap.this.maxSize);
                        while (runs-- > 0) {
                            Element evict = nextExpiredOrToEvict(value);
                            if (evict != null) {
                                evicted[runs] = (remove(evict.getKey(), hash(evict.getKey().hashCode()), null));
                            }
                        }


net.sf.ehcache.store.MemoryStore

private void checkCapacity(final Element elementJustAdded) {
        if (maximumSize > 0 && !isClockEviction()) {
            int evict = Math.min(map.quickSize() - maximumSize, MAX_EVICTION_RATIO);
            for (int i = 0; i < evict; i++) {
                removeElementChosenByEvictionPolicy(elementJustAdded);
            }
        }
    }
其实外国人写的代码也就那样,也很乱。

热点排行