亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? cache.java

?? Jive論壇2.5版本的源程序
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
     * @param key a unique key for the object being put into cache.
     * @param object the Cacheable object to put into cache.
     */
    public synchronized void add(Object key, Cacheable object) {
        // Delete an old entry if it exists.
        remove(key);

        int objectSize = object.getSize();
        // If the object is bigger than the entire cache, simply don't add it.
        if (objectSize > maxSize * .90) {
            return;
        }
        size += objectSize;
        CacheObject cacheObject = new CacheObject(object, objectSize);
        cachedObjectsHash.put(key, cacheObject);
        // Make an entry into the cache order list.
        LinkedListNode lastAccessedNode = lastAccessedList.addFirst(key);
        // Store the cache order list entry so that we can get back to it
        // during later lookups.
        cacheObject.lastAccessedListNode = lastAccessedNode;
        // Add the object to the age list
        LinkedListNode ageNode = ageList.addFirst(key);
        // We make an explicit call to currentTimeMillis() so that total accuracy
        // of lifetime calculations is better than one second.
        ageNode.timestamp = System.currentTimeMillis();
        cacheObject.ageListNode = ageNode;

        // If cache is too full, remove least used cache entries until it is
        // not too full.
        cullCache();
    }

    /**
     * Gets an object from cache. This method will return null under two
     * conditions:<ul>
     *    <li>The object referenced by the key was never added to cache.
     *    <li>The object referenced by the key has expired from cache.</ul>
     *
     * @param key the unique key of the object to get.
     * @return the Cacheable object corresponding to unique key.
     */
    public synchronized Cacheable get(Object key) {
        // First, clear all entries that have been in cache longer than the
        // maximum defined age.
        deleteExpiredEntries();

        CacheObject cacheObject = (CacheObject)cachedObjectsHash.get(key);
        if (cacheObject == null) {
            // The object didn't exist in cache, so increment cache misses.
            cacheMisses++;
            return null;
        }

        // The object exists in cache, so increment cache hits.
        cacheHits++;

        // Remove the object from it's current place in the cache order list,
        // and re-insert it at the front of the list.
        cacheObject.lastAccessedListNode.remove();
        lastAccessedList.addFirst(cacheObject.lastAccessedListNode);

        return cacheObject.object;
    }

    /**
     * Removes an object from cache.
     *
     * @param key the unique key of the object to remove.
     */
    public synchronized void remove(Object key) {
        CacheObject cacheObject = (CacheObject)cachedObjectsHash.get(key);
        // If the object is not in cache, stop trying to remove it.
        if (cacheObject == null) {
            return;
        }
        // remove from the hash map
        cachedObjectsHash.remove(key);
        // remove from the cache order list
        cacheObject.lastAccessedListNode.remove();
        cacheObject.ageListNode.remove();
        // remove references to linked list nodes
        cacheObject.ageListNode = null;
        cacheObject.lastAccessedListNode = null;
        // removed the object, so subtract its size from the total.
        size -= cacheObject.size;
    }

    /**
     * Clears the cache of all objects. The size of the cache is reset to 0.
     */
    public synchronized void clear() {
        Object [] keys = cachedObjectsHash.keySet().toArray();
        for (int i=0; i<keys.length; i++) {
            remove(keys[i]);
        }

        // Now, reset all containers.
        cachedObjectsHash.clear();
        cachedObjectsHash = new HashMap(103);
        lastAccessedList.clear();
        lastAccessedList = new LinkedList();
        ageList.clear();
        ageList = new LinkedList();

        size = 0;
        cacheHits = 0;
        cacheMisses = 0;
    }

    /**
     * Returns an array of the keys contained in the cache.
     *
     * @return an array of the keys present in the cache.
     */
    public Object [] keys() {
        return cachedObjectsHash.keySet().toArray();
    }

    /**
     * Returns an array of the values contained in the cache.
     *
     * @return a array of the cache entries.
     */
    public Object [] values() {
        Object [] cacheObjects = cachedObjectsHash.values().toArray();
        Object [] values = new Object[cacheObjects.length];
        for (int i=0; i<cacheObjects.length; i++) {
            values[i] = ((CacheObject)cacheObjects[i]).object;
        }
        return values;
    }

    /**
     * Returns the number of cache hits. A cache hit occurs every
     * time the get method is called and the cache contains the requested
     * object.<p>
     *
     * Keeping track of cache hits and misses lets one measure how efficient
     * the cache is; the higher the percentage of hits, the more efficient.
     *
     * @return the number of cache hits.
     */
    public long getCacheHits() {
        return cacheHits;
    }

    /**
     * Returns the number of cache misses. A cache miss occurs every
     * time the get method is called and the cache does not contain the
     * requested object.<p>
     *
     * Keeping track of cache hits and misses lets one measure how efficient
     * the cache is; the higher the percentage of hits, the more efficient.
     *
     * @return the number of cache hits.
     */
    public long getCacheMisses() {
        return cacheMisses;
    }

    /**
     * Clears all entries out of cache where the entries are older than the
     * maximum defined age.
     */
    private final void deleteExpiredEntries() {
        //Check if expiration is turned on.
        if (maxLifetime <= 0) {
            return;
        }

        // Remove all old entries. To do this, we remove objects from the end
        // of the linked list until they are no longer too old. We get to avoid
        // any hash lookups or looking at any more objects than is strictly
        // neccessary.
        LinkedListNode node = ageList.getLast();
        //If there are no entries in the age list, return.
        if (node == null) {
            return;
        }

        // Determine the expireTime, which is the moment in time that elements
        // should expire from cache. Then, we can do an easy to check to see
        // if the expire time is greater than the expire time.
        long expireTime = currentTime - maxLifetime;

        while(expireTime > node.timestamp) {
            // Remove the object
            remove(node.object);

            // Get the next node.
            node = ageList.getLast();
            // If there are no more entries in the age list, return.
            if (node == null) {
                return;
            }
        }
    }

    /**
     * Removes objects from cache if the cache is too full. "Too full" is
     * defined as within 3% of the maximum cache size. Whenever the cache is
     * is too big, the least frequently used elements are deleted until the
     * cache is at least 10% empty.
     */
    private final void cullCache() {
        // See if the cache size is within 3% of being too big. If so, clean out
        // cache until it's 10% free.
        if (size >= maxSize * .97) {
            // First, delete any old entries to see how much memory that frees.
            deleteExpiredEntries();
            int desiredSize = (int)(maxSize * .90);
            while (size > desiredSize) {
                // Get the key and invoke the remove method on it.
                remove(lastAccessedList.getLast().object);
            }
        }
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲va欧美va天堂v国产综合| 精品国免费一区二区三区| 日本成人中文字幕在线视频| 国产精品久久久久久久岛一牛影视| 欧美午夜精品一区二区蜜桃| 成人午夜视频网站| 麻豆国产精品官网| 亚洲综合一区二区精品导航| 日本一区二区三区四区在线视频| 91精品国产一区二区三区| 97se亚洲国产综合自在线不卡| 精品一区二区在线播放| 亚洲福利国产精品| 成人欧美一区二区三区白人| 久久久精品国产99久久精品芒果 | 91福利资源站| 成人黄色在线视频| 国内精品久久久久影院色| 天天操天天干天天综合网| 一区二区三区不卡视频| 综合久久久久久久| 国产欧美一区二区三区鸳鸯浴 | 欧美一区二区三区系列电影| 色婷婷综合久久久中文字幕| 成人av在线影院| 国产成人午夜99999| 国内偷窥港台综合视频在线播放| 91激情在线视频| 成人少妇影院yyyy| 成人h动漫精品一区二区| 成人性生交大片免费看视频在线| 国产91清纯白嫩初高中在线观看| 国产在线视频一区二区三区| 另类小说综合欧美亚洲| 青青草成人在线观看| 日日骚欧美日韩| 日韩和欧美一区二区| 日韩中文字幕一区二区三区| 日日夜夜精品视频天天综合网| 性久久久久久久久久久久| 五月综合激情网| 日本在线不卡一区| 美美哒免费高清在线观看视频一区二区 | 国产精品自在在线| 国产一区二区美女| 国产馆精品极品| caoporn国产一区二区| 一本色道a无线码一区v| 91黄视频在线观看| 在线观看91精品国产麻豆| 欧美一区午夜视频在线观看| 日韩一级视频免费观看在线| 精品成人a区在线观看| 国产欧美1区2区3区| 亚洲色图另类专区| 亚洲午夜激情av| 久久精品免费看| 国产精品18久久久久| 成人免费av资源| 欧美日韩在线三级| 亚洲123区在线观看| 蜜臀av一区二区在线免费观看| 黄页视频在线91| av不卡在线观看| 欧美精品免费视频| 久久欧美一区二区| 中文字幕一区在线观看视频| 亚洲一区av在线| 韩国一区二区视频| 91视频国产观看| 欧美一级欧美一级在线播放| 国产亚洲精久久久久久| 亚洲丝袜另类动漫二区| 婷婷开心激情综合| 国内精品免费在线观看| 日本精品一区二区三区高清| 日韩欧美国产成人一区二区| 国产精品久久久久永久免费观看 | 蜜乳av一区二区| 成人性视频网站| 制服丝袜亚洲播放| 久久久久久久久久久久久女国产乱 | 欧美不卡一区二区| 国产精品天干天干在线综合| 亚洲成人av一区二区| 精品福利一区二区三区免费视频| 欧美经典三级视频一区二区三区| 一区二区三区四区不卡视频| 美女爽到高潮91| 色94色欧美sute亚洲线路一久| 欧美v国产在线一区二区三区| 亚洲视频免费看| 国产又黄又大久久| 欧美日韩视频第一区| 国产精品沙发午睡系列990531| 免费一区二区视频| 一本一道久久a久久精品综合蜜臀| 欧美电影免费观看完整版| 一区二区三区影院| 成人久久久精品乱码一区二区三区| 91精选在线观看| 最新日韩在线视频| 国产精品99久| 欧美巨大另类极品videosbest| 中文字幕乱码亚洲精品一区| 精品一区二区免费在线观看| 欧美色综合久久| 自拍av一区二区三区| 国产精品18久久久| 精品久久五月天| 日韩av中文字幕一区二区| 日本韩国欧美三级| 国产精品色婷婷久久58| 国产黄人亚洲片| 久久久综合精品| 狠狠狠色丁香婷婷综合激情| 884aa四虎影成人精品一区| 亚洲午夜日本在线观看| 97se亚洲国产综合自在线观| 国产精品久久久久一区二区三区共 | 欧美一区二区在线看| 亚洲国产精品麻豆| 91碰在线视频| 亚洲精品视频免费观看| 成人免费看视频| 国产精品亲子乱子伦xxxx裸| 成人性视频免费网站| 欧美国产亚洲另类动漫| 国产精品一区二区在线看| 欧美精品一区二区不卡| 精品亚洲欧美一区| xnxx国产精品| 久久婷婷色综合| 国产裸体歌舞团一区二区| 精品国产一区二区三区久久影院 | 激情偷乱视频一区二区三区| 日韩三级av在线播放| 蜜臀av性久久久久蜜臀aⅴ四虎| 欧美一个色资源| 韩国av一区二区三区在线观看| 久久日韩精品一区二区五区| 国产一区二区三区黄视频| 久久久久久久综合日本| 成人免费高清在线| 亚洲欧美激情一区二区| 色88888久久久久久影院按摩| 亚洲综合在线观看视频| 欧美无砖砖区免费| 奇米888四色在线精品| 日韩你懂的电影在线观看| 国产成人午夜视频| 亚洲品质自拍视频| 欧美美女bb生活片| 久久成人免费网站| 国产欧美一区二区三区鸳鸯浴| 99久久久精品| 日韩专区一卡二卡| 国产日韩精品视频一区| 91一区一区三区| 丝袜亚洲精品中文字幕一区| 久久免费国产精品| 色综合天天综合网天天看片| 日韩电影一区二区三区四区| 久久嫩草精品久久久久| 91麻豆国产香蕉久久精品| 日本欧美一区二区三区| 久久久不卡影院| 91成人免费电影| 久久99精品国产麻豆不卡| 国产精品美女一区二区三区| 欧美在线999| 国产在线视频一区二区三区| 亚洲乱码中文字幕综合| 制服丝袜亚洲精品中文字幕| 高清不卡一区二区| 午夜精品久久一牛影视| 国产精品网曝门| 91精品久久久久久久91蜜桃| av亚洲精华国产精华| 爽爽淫人综合网网站| 中文字幕av不卡| 欧美一区二区视频在线观看2022| 国产传媒欧美日韩成人| 亚洲成av人片| 国产精品国产精品国产专区不片| 在线观看91精品国产麻豆| 成人晚上爱看视频| 美女在线一区二区| 一区二区高清免费观看影视大全 | 亚洲视频在线观看一区| 日韩视频在线观看一区二区| 91丨porny丨首页| 国产一区二区三区黄视频| 亚洲综合视频网| 国产精品美女一区二区在线观看| 日韩免费性生活视频播放| 欧洲精品在线观看| 成人黄页在线观看| 国产一区二区三区免费| 日一区二区三区|