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

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

?? cache.java

?? Jive(J道版) Jive(J道版)是在Jive 2.1版本基礎上改編而成
?? 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一区二区三区免费野_久草精品视频
亚洲综合一区在线| 亚洲欧美国产毛片在线| 国产成人综合视频| 九九**精品视频免费播放| 亚洲欧美日韩一区| 日本一区二区视频在线| 欧美一区二区三区影视| 99久久综合色| 国产在线播精品第三| 一区二区三区蜜桃网| 日韩中文字幕1| 精品欧美乱码久久久久久| 色综合久久综合网欧美综合网| 国产成人av电影在线播放| 国产成人超碰人人澡人人澡| 精品亚洲国产成人av制服丝袜| 久久精品国产第一区二区三区| 青草国产精品久久久久久| 蜜芽一区二区三区| 乱一区二区av| 国产不卡在线视频| 91麻豆福利精品推荐| 欧洲视频一区二区| 欧美一区二区大片| 久久午夜免费电影| 中文字幕av不卡| 亚洲欧美另类图片小说| 亚洲精品菠萝久久久久久久| 婷婷久久综合九色综合伊人色| 亚洲成人av在线电影| 美女看a上一区| 国产成人在线观看免费网站| 97国产精品videossex| 欧美色综合网站| 精品日韩99亚洲| 亚洲三级久久久| 日本va欧美va欧美va精品| 国产成人综合视频| 91福利在线看| 亚洲精品在线免费观看视频| 国产精品成人网| 天天做天天摸天天爽国产一区 | 成人av在线网站| 欧美三片在线视频观看| 2023国产精华国产精品| 一区二区三区四区在线免费观看| 青娱乐精品视频| 91色九色蝌蚪| 久久综合九色综合欧美98 | 精品一区二区影视| 精品一区二区在线视频| 成人午夜电影网站| 欧美一区二区三区四区高清 | 成人爱爱电影网址| 亚洲人成精品久久久久| 精品国产百合女同互慰| 激情成人午夜视频| 日韩一区中文字幕| 色av一区二区| 午夜欧美视频在线观看| 欧美日韩久久一区| 国产成人精品午夜视频免费| 日韩美女啊v在线免费观看| www.66久久| a4yy欧美一区二区三区| 精品国产三级电影在线观看| 亚洲国产日韩综合久久精品| 岛国精品在线观看| 亚洲精品一区二区三区精华液| 亚洲一区二区在线免费看| 波多野结衣一区二区三区| 久久久久久一二三区| 另类调教123区| 日韩一级完整毛片| 日韩一区精品视频| 7777精品伊人久久久大香线蕉经典版下载| 国产精品初高中害羞小美女文| 国产成人精品综合在线观看| 精品国产青草久久久久福利| 男女男精品视频| 欧美日韩国产乱码电影| 亚洲电影一级黄| 欧美日精品一区视频| 一区二区三区日韩精品视频| 色诱视频网站一区| 亚洲自拍都市欧美小说| 欧美日韩情趣电影| 亚洲sss视频在线视频| 欧美日韩另类一区| 免费日韩伦理电影| 久久久久亚洲蜜桃| av激情亚洲男人天堂| 亚洲日本va午夜在线影院| 一本色道a无线码一区v| 亚洲福利一二三区| 日韩视频一区二区三区在线播放| 蜜臀av在线播放一区二区三区| 亚洲精品在线免费观看视频| 国产成人精品1024| 亚洲欧美国产77777| 欧美日韩免费电影| 国内精品视频666| 国产精品麻豆欧美日韩ww| 一本大道久久a久久精二百| 五月天精品一区二区三区| 久久蜜桃一区二区| 91麻豆自制传媒国产之光| 午夜精品视频在线观看| 精品国产电影一区二区| 91在线国内视频| 美女在线观看视频一区二区| 国产欧美一区二区精品性色| 91国偷自产一区二区开放时间| 日韩av中文在线观看| 蓝色福利精品导航| 色婷婷综合在线| 五月婷婷激情综合网| 欧美电影一区二区三区| 一区二区三区日韩| 国产一区二区网址| 欧美精品一区二区三区蜜桃| 国产精品久久久久精k8| 麻豆精品视频在线观看免费| 99国产精品99久久久久久| wwww国产精品欧美| 美女精品一区二区| 久久久久久日产精品| 亚洲大片精品永久免费| 精品国产自在久精品国产| 色综合久久综合| 狠狠色狠狠色合久久伊人| 中文字幕中文字幕在线一区 | 91免费视频大全| 久久精品国产亚洲高清剧情介绍 | 日韩理论片网站| 日韩欧美www| 欧美写真视频网站| 97aⅴ精品视频一二三区| 精品一区二区在线观看| 日韩av不卡在线观看| 亚洲欧美日韩电影| 成人欧美一区二区三区视频网页| 欧美成人性战久久| 91精品国产综合久久精品app| 91一区二区三区在线观看| 国产成人精品一区二区三区四区 | 亚洲三级小视频| 国产日本亚洲高清| www激情久久| 日韩视频永久免费| 日韩视频免费观看高清完整版在线观看| 91在线视频免费91| 91色porny在线视频| 一本色道久久综合亚洲aⅴ蜜桃 | av在线播放一区二区三区| 国产一区二区三区四区五区美女| 青青草精品视频| 久久99精品久久久久久久久久久久 | 欧美日本在线播放| 欧美午夜在线观看| 97超碰欧美中文字幕| 色综合激情五月| 在线观看亚洲精品视频| 成人av电影在线观看| 国产精品综合在线视频| 狠狠色2019综合网| 久久综合色天天久久综合图片| 正在播放一区二区| 欧美另类久久久品| 欧美性色综合网| av不卡免费电影| 国产高清精品久久久久| 日韩精品亚洲专区| 午夜欧美2019年伦理| 亚洲国产精品综合小说图片区| 国产农村妇女毛片精品久久麻豆 | 欧美激情在线观看视频免费| 日韩精品一区二区三区在线播放| 在线播放视频一区| 日韩欧美视频一区| 久久久亚洲国产美女国产盗摄| 中文字幕成人av| 亚洲一级不卡视频| 黄色精品一二区| 不卡的av在线| 在线播放/欧美激情| 久久午夜羞羞影院免费观看| 国产精品国产自产拍在线| 亚洲精品欧美激情| 美女网站视频久久| 99视频一区二区| 91精品国产乱码| 国产精品视频yy9299一区| 亚洲国产cao| 国产91精品精华液一区二区三区 | 午夜欧美在线一二页| 国产精品亚洲综合一区在线观看| 一本大道久久a久久精二百| 日韩一区二区三区免费观看| 国产欧美精品一区aⅴ影院 |