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

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

?? cache.java

?? Jvie論壇的程序
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
     * Sets the maximum size of the cache in bytes. If the cache grows too
     * large, the least frequently used items will automatically be deleted so
     * that the cache size doesn't exceed the maximum.
     *
     * @param maxSize the maximum size of the cache in bytes.
     */
    public void setMaxSize(int maxSize) {
        this.maxSize = maxSize;
        //It's possible that the new max size is smaller than our current cache
        //size. If so, we need to delete infrequently used items.
        cullCache();
    }

    /**
     * Returns the number of objects in the cache.
     *
     * @return the number of objects in the cache.
     */
    public synchronized int getNumElements() {
        return cachedObjectsHash.size();
    }

    /**
     * Adds a new Cacheable object to the cache. The key must be unique.
     *
     * @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) {
        //DEBUG
        //System.err.println("Adding object with key " + key + " to hash " + this);

        //Don't add an object with the same key multiple times.
        if (cachedObjectsHash.containsKey(key)) {
            return;
        }
        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) {
        //DEBUG
        //System.err.println("Removing object with key: " + key + " from hash " + this);

        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() {
        //DEBUG
        //System.err.println("Clearing cache " + this);

        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 a collection view of the values contained in the cache.
     * The Collection is unmodifiable to prevent cache integrity issues.
     *
     * @return a Collection of the cache entries.
     */
    public Collection values() {
        return Collections.unmodifiableCollection(cachedObjectsHash.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) {
            //DEBUG
            //System.err.println("Object with key " + node.object + " expired.");

            //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在线| 婷婷激情综合网| 成人综合在线视频| 色香色香欲天天天影视综合网| 欧美激情资源网| 欧美一区二视频| 色欧美88888久久久久久影院| 国产一区三区三区| 亚洲va在线va天堂| 国产精品成人免费精品自在线观看 | 美腿丝袜在线亚洲一区| 亚洲免费看黄网站| 国产女同性恋一区二区| 日韩欧美国产综合一区| 欧美日韩国产欧美日美国产精品| 99综合电影在线视频| 国产精品66部| 精品一区二区国语对白| 午夜精品123| 亚洲第一主播视频| 亚洲自拍偷拍av| 亚洲一区二区视频在线观看| 亚洲色图欧美偷拍| 亚洲欧美在线视频观看| 国产精品丝袜黑色高跟| 久久精品人人做| 欧美精品一区二区久久久| 日韩一区二区在线观看视频播放| 欧美四级电影网| 欧美三级视频在线观看| 欧美日韩精品专区| 欧美日韩另类一区| 欧美精品乱码久久久久久按摩| 91一区一区三区| 色婷婷亚洲一区二区三区| 色香蕉成人二区免费| 色哟哟在线观看一区二区三区| 色综合久久中文字幕| 在线免费观看日韩欧美| 欧美伊人精品成人久久综合97| 色狠狠综合天天综合综合| 91精品福利在线| 欧美精品在线一区二区| 日韩一区二区三区观看| 久久亚洲综合色一区二区三区| 欧美成人激情免费网| 精品99一区二区| 欧美激情综合五月色丁香| 亚洲色图视频网站| 夜夜揉揉日日人人青青一国产精品| 一个色综合网站| 日韩高清欧美激情| 久久99久国产精品黄毛片色诱| 国产曰批免费观看久久久| 国产成人精品三级麻豆| 成人高清在线视频| 欧美伊人久久大香线蕉综合69| 欧美另类z0zxhd电影| 日韩精品最新网址| 国产丝袜美腿一区二区三区| 成人免费一区二区三区视频 | 欧美精品日韩精品| 日韩免费视频一区| 国产精品美女久久久久久| 亚洲欧美电影院| 蜜臀精品一区二区三区在线观看 | 欧美日韩另类一区| 日韩美女主播在线视频一区二区三区| 久久夜色精品一区| 亚洲男人的天堂av| 免费在线视频一区| 国产v综合v亚洲欧| 欧美三级视频在线| 久久奇米777| 亚洲一区二区在线免费观看视频| 美女视频一区二区| 99国产精品视频免费观看| 欧美日韩在线直播| 国产女主播一区| 亚洲成av人片| 成人精品国产一区二区4080| 精品视频免费在线| 国产欧美精品区一区二区三区 | 成人三级在线视频| 欧美日本精品一区二区三区| 国产女同性恋一区二区| 天天操天天综合网| gogogo免费视频观看亚洲一| 91精品中文字幕一区二区三区| 欧美国产在线观看| 日本美女一区二区三区视频| 成人永久免费视频| 欧美一级高清片在线观看| 国产精品色哟哟| 麻豆精品在线观看| 欧美亚洲精品一区| 中文字幕免费不卡在线| 蜜臀av性久久久久av蜜臀妖精| 91丨九色丨国产丨porny| 欧美sm极限捆绑bd| 午夜欧美电影在线观看| 91同城在线观看| 国产视频在线观看一区二区三区| 奇米精品一区二区三区四区| 色一情一乱一乱一91av| 国产精品―色哟哟| 国产成人精品影视| 久久久五月婷婷| 麻豆传媒一区二区三区| 欧美高清你懂得| 一区二区激情视频| 91美女在线看| 中文字幕一区二区三区不卡| 粉嫩aⅴ一区二区三区四区五区| 日韩免费观看2025年上映的电影| 手机精品视频在线观看| 欧美系列一区二区| 一区二区三区免费看视频| av网站一区二区三区| 亚洲国产激情av| 成人免费观看av| 亚洲国产精品成人久久综合一区 | 777奇米四色成人影色区| 亚洲国产精品一区二区久久 | 欧美精品一二三四| 成人精品小蝌蚪| 午夜精品久久久久久久| 欧美大片一区二区三区| 91女神在线视频| 国产99久久久国产精品潘金网站| 五月天国产精品| 亚洲免费观看高清完整版在线观看熊 | 色婷婷久久久亚洲一区二区三区| 亚洲欧洲精品成人久久奇米网| 成人高清免费在线播放| 久久久美女毛片| 国产乱子伦一区二区三区国色天香| 日韩欧美在线1卡| 韩国女主播一区| 亚洲国产成人午夜在线一区| 99在线精品视频| 亚洲综合色自拍一区| 欧美日韩免费观看一区二区三区 | 日本乱人伦一区| 亚洲男人电影天堂| 欧美日韩一区中文字幕| 无码av中文一区二区三区桃花岛| 欧美丰满美乳xxx高潮www| 日本在线不卡一区| 精品剧情在线观看| 国产高清精品在线| 中文字幕一区三区| 在线免费不卡电影| 男男gaygay亚洲| ...中文天堂在线一区| 在线看国产一区二区| 人人爽香蕉精品| 国产欧美日韩激情| 欧美午夜一区二区| 免费欧美在线视频| 亚洲国产精品成人综合| 91高清视频在线| 久久精品国产99久久6| 欧美高清在线精品一区| 色婷婷久久久亚洲一区二区三区| 日韩精品亚洲专区| 久久久久久久久99精品| 色婷婷久久久亚洲一区二区三区| 日韩精彩视频在线观看| 国产香蕉久久精品综合网| 日本丶国产丶欧美色综合| 蜜桃精品视频在线| 国产精品久久久久aaaa樱花| 欧美网站一区二区| 国产成人在线色| 亚洲成人自拍偷拍| 亚洲国产经典视频| 欧美高清dvd| 不卡一卡二卡三乱码免费网站| 亚洲国产日韩一区二区| 国产人成亚洲第一网站在线播放| 91在线精品秘密一区二区| 美女视频网站久久| 亚洲愉拍自拍另类高清精品| 国产午夜精品久久久久久免费视 | 99久久精品国产麻豆演员表| 免费美女久久99| 亚洲精品第1页| 国产亚洲欧美日韩俺去了| 欧美日韩一本到| 成人免费福利片| 男女视频一区二区| 亚洲国产精品久久久男人的天堂| 欧美激情一区二区三区在线| 日韩精品资源二区在线| 欧美日韩国产首页| 色噜噜狠狠色综合欧洲selulu| 国产一区高清在线|