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

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

?? cache.java

?? jive Study
?? 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一区二区三区免费野_久草精品视频
91精品国产品国语在线不卡| 九九久久精品视频| 99re6这里只有精品视频在线观看| 国产三级欧美三级日产三级99| 国模一区二区三区白浆| 欧美韩国日本综合| 99综合影院在线| 亚洲国产欧美一区二区三区丁香婷| 欧美日韩精品欧美日韩精品一| 午夜视频久久久久久| 精品国产91亚洲一区二区三区婷婷 | 色噜噜久久综合| 亚洲国产精品久久不卡毛片| 欧美欧美午夜aⅴ在线观看| 另类人妖一区二区av| 国产欧美一区二区精品婷婷| 色综合久久综合网97色综合| 婷婷久久综合九色综合绿巨人| 欧美大度的电影原声| 成人午夜免费视频| 成人综合在线网站| 一区二区三区四区中文字幕| 91精品国产色综合久久不卡蜜臀| 国产在线不卡一区| 亚洲激情五月婷婷| 欧美mv日韩mv国产| 色一情一乱一乱一91av| 日韩精品视频网| 中文字幕国产一区二区| 717成人午夜免费福利电影| 国产成人免费视频| 亚洲va天堂va国产va久| 国产日韩影视精品| 欧美精品乱码久久久久久| 成人18视频在线播放| 美女视频黄频大全不卡视频在线播放| 久久久午夜电影| 欧美精品久久99| 99久久国产综合精品色伊| 青草av.久久免费一区| 亚洲欧美日韩精品久久久久| 精品不卡在线视频| 9191久久久久久久久久久| 成人综合婷婷国产精品久久免费| 天天操天天色综合| 成人欧美一区二区三区视频网页 | 欧美综合亚洲图片综合区| 国产呦精品一区二区三区网站| 一区2区3区在线看| 国产精品萝li| 久久―日本道色综合久久| 欧美理论在线播放| 91九色02白丝porn| 99精品偷自拍| 国产成人综合亚洲网站| 麻豆国产欧美一区二区三区| 亚洲成a天堂v人片| 洋洋av久久久久久久一区| 国产精品女上位| 久久―日本道色综合久久| 日韩免费视频一区二区| 91精品国产91综合久久蜜臀| 欧美性做爰猛烈叫床潮| 色婷婷综合久久| 91捆绑美女网站| 91小视频在线观看| 91丝袜呻吟高潮美腿白嫩在线观看| 国产伦精品一区二区三区视频青涩| 美脚の诱脚舐め脚责91| 免费人成在线不卡| 美女网站视频久久| 琪琪久久久久日韩精品| 天天综合天天做天天综合| 亚洲一区二区在线观看视频| 一区2区3区在线看| 亚洲福利视频一区二区| 亚洲国产精品久久久久秋霞影院 | 乱一区二区av| 九一久久久久久| 国产精品538一区二区在线| 国产精品综合视频| 成人性生交大合| 国产亚洲综合色| 久久久久久久网| 国产精品久久久久桃色tv| 1区2区3区精品视频| 樱桃视频在线观看一区| 一区二区三区四区高清精品免费观看| 亚洲制服丝袜av| 日韩中文字幕麻豆| 麻豆一区二区三| 国产精品白丝jk白祙喷水网站| 国产成人精品网址| 91福利在线看| 欧美成人精品1314www| 久久久久一区二区三区四区| 日本一区二区高清| 一区二区三区在线视频观看| 图片区日韩欧美亚洲| 黄网站免费久久| 成人一区在线看| 欧美午夜视频网站| 精品99一区二区三区| 国产精品短视频| 天堂影院一区二区| 国产成人8x视频一区二区 | 久久激情五月激情| 成人午夜精品一区二区三区| 欧美视频在线一区二区三区 | 成人国产免费视频| 欧美日韩亚洲国产综合| www国产精品av| 亚洲精品免费看| 久久国产婷婷国产香蕉| 91玉足脚交白嫩脚丫在线播放| 欧美猛男超大videosgay| 久久久久国产精品人| 亚洲高清不卡在线观看| 国产成人在线观看| 欧美日韩国产中文| 国产精品嫩草99a| 免费观看91视频大全| 91免费国产在线观看| 欧美成人精品福利| 亚洲资源中文字幕| 国产成人99久久亚洲综合精品| 欧美日韩在线电影| 国产精品久久久爽爽爽麻豆色哟哟| 日韩不卡免费视频| 99久久国产免费看| 久久久精品影视| 图片区小说区区亚洲影院| 91在线精品一区二区三区| 欧美α欧美αv大片| 一区二区三区在线观看网站| 国产一区二区三区四区在线观看| 欧美伊人精品成人久久综合97 | 精品综合免费视频观看| 色综合天天综合网国产成人综合天 | 丝袜亚洲另类欧美| 99re在线视频这里只有精品| 久久午夜色播影院免费高清| 丝袜亚洲另类丝袜在线| 91精品1区2区| 亚洲色图20p| 成人av在线电影| 久久精品视频免费| 久久精品国产网站| 91麻豆精品国产91久久久久| 亚洲影院久久精品| 91在线视频网址| 国产精品三级av| 岛国精品在线观看| 久久久综合视频| 国产真实乱偷精品视频免| 日韩一区二区影院| 日日噜噜夜夜狠狠视频欧美人| 日本高清免费不卡视频| 亚洲欧美视频在线观看视频| www.一区二区| 国产精品久久久久久一区二区三区 | 狠狠色狠狠色合久久伊人| 欧美日韩国产系列| 一区二区免费看| 在线观看av不卡| 亚洲一区二区三区视频在线播放 | 欧美色图激情小说| 一区二区三区蜜桃网| 在线视频国内一区二区| 一区二区三区精品在线| 在线免费不卡视频| 午夜成人免费电影| 日韩免费电影一区| 国产一区二区精品在线观看| 久久久久久久久久美女| 成人av网址在线| 一区二区三区免费观看| 欧美三级电影网| 久久精品理论片| 欧美国产在线观看| 91免费国产在线观看| 午夜精品一区二区三区三上悠亚| 欧美日韩国产美| 日韩成人精品视频| 国产午夜亚洲精品理论片色戒 | 风间由美一区二区av101| 欧美激情综合五月色丁香小说| 大美女一区二区三区| 亚洲三级在线播放| 欧美夫妻性生活| 国产成人在线免费| 一区二区在线免费观看| 日韩午夜在线观看视频| 国产成人小视频| 一区二区理论电影在线观看| 欧美夫妻性生活| 成人毛片视频在线观看| 亚洲国产一区二区在线播放| 日韩一级片网址| 99久久婷婷国产综合精品电影 |