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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? cache.java

?? Jive論壇2.5版本的源程序
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/**
 * $RCSfile: Cache.java,v $
 * $Revision: 1.1.1.1 $
 * $Date: 2002/09/09 13:51:09 $
 *
 * New Jive  from Jdon.com.
 *
 * This software is the proprietary information of CoolServlets, Inc.
 * Use is subject to license terms.
 */

package com.jivesoftware.util;

import java.util.*;
import com.jivesoftware.util.LinkedList;

/**
 * General purpose cache implementation. It stores objects associated with
 * unique keys in memory for fast access. All objects added to the cache must
 * implement the Cacheable interface, which requires objects to know their
 * size in memory. This restrictions allows the cache to never grow larger
 * than a specified amount.<p>
 *
 * If the cache does grow too large, objects will be removed such that those
 * that are accessed least frequently are removed first. Because expiration
 * happens automatically, the cache makes <b>no</b> gaurantee as to how long
 * an object will remain in cache after it is put in. The cache will return
 * null if the requested object is not found.<p>
 *
 * Optionally, a maximum lifetime for all objects can be specified. In that
 * case, objects will be deleted from cache after that amount of time, even
 * if they are frequently accessed. This feature is useful if objects put in
 * cache represent data that should be periodically refreshed; for example,
 * information from a database.<p>
 *
 * Cache is optimized for fast data access. The getObject() method has 0(n)
 * performance regardless of cache size. The other cache operations also
 * perform quite fast.<p>
 *
 * Cache objects are thread safe.<p>
 *
 * The algorithm for cache is as follows: a HashMap is maintained for fast
 * object lookup. Two linked lists are maintained: one keeps objects in the
 * order they are accessed from cache, the other keeps objects in the order
 * they were originally added to cache. When objects are added to cache, they
 * are first wrapped by a CacheObject which maintains the following pieces
 * of information:<ul>
 *    <li> The size of the object (in bytes).
 *    <li> A pointer to the node in the linked list that maintains accessed
 *         order for the object. Keeping a reference to the node lets us avoid
 *         linear scans of the linked list.
 *    <li> A pointer to the node in the linked list that maintains the age
 *         of the object in cache. Keeping a reference to the node lets us avoid
 *         linear scans of the linked list.</ul>
 *
 * To get an object from cache, a hash lookup is performed to get a reference
 * to the CacheObject that wraps the real object we are looking for.
 * The object is subsequently moved to the front of the accessed linked list
 * and any necessary cache cleanups are performed. Cache deletion and expiration
 * is performed as needed.
 *
 * @see Cacheable
 */
public class Cache implements Cacheable {

    /**
     * One of the major potential bottlenecks of the cache is performing
     * System.currentTimeMillis() for every cache get operation. Instead,
     * we maintain a global timestamp that gets updated once a second. This
     * means that cache expirations can be no more than one second accurate.
     */
    protected static long currentTime = CacheTimer.currentTime;

    /**
     * Maintains the hash of cached objects. Hashing provides the best
     * performance for fast lookups.
     */
    protected HashMap cachedObjectsHash;

    /**
     * Linked list to maintain order that cache objects are accessed
     * in, most used to least used.
     */
    protected LinkedList lastAccessedList;

    /**
     * Linked list to maintain time that cache objects were initially added
     * to the cache, most recently added to oldest added.
     */
    protected LinkedList ageList;

   /**
    * Maximum size in bytes that the cache can grow to. Default
    * maximum size is 128 K.
    */
    protected int maxSize =  128 * 1024;

    /**
     * Maintains the current size of the cache in bytes.
     */
    protected int size = 0;

    /**
     * Maximum length of time objects can exist in cache before expiring.
     * Default is that objects have no maximum lifetime.
     */
    protected long maxLifetime = -1;

    /**
     * Maintain the number of cache hits and misses. A cache hit occurs every
     * time the get method is called and the cache contains the requested
     * object. A cache miss represents the opposite occurence.<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.
     */
    protected long cacheHits, cacheMisses = 0L;

    /**
     * Create a new cache with default values. Default cache size is 128K with
     * no maximum lifetime.
     */
    public Cache() {
        // Our primary data structure is a hash map. The default capacity of 11
        // is too small in almost all cases, so we set it bigger.
        cachedObjectsHash = new HashMap(103);

        lastAccessedList = new LinkedList();
        ageList = new LinkedList();
    }

    /**
     * Create a new cache and specify the maximum size for the cache in bytes.
     * Items added to the cache will have no maximum lifetime.
     *
     * @param maxSize the maximum size of the cache in bytes.
     */
    public Cache(int maxSize) {
        this();
        this.maxSize = maxSize;
    }

    /**
     * Create a new cache and specify the maximum lifetime of objects. The
     * time should be specified in milleseconds. The minimum lifetime of any
     * cache object is 1000 milleseconds (1 second). Additionally, cache
     * expirations have a 1000 millesecond resolution, which means that all
     * objects are guaranteed to be expired within 1000 milliseconds of their
     * maximum lifetime.
     *
     * @param maxLifetime the maximum amount of time objects can exist in
     *    cache before being deleted.
     */
    public Cache(long maxLifetime) {
        this();
        this.maxLifetime = maxLifetime;
    }

    /**
     * Create a new cache and specify the maximum size of for the cache in
     * bytes, and the maximum lifetime of objects.
     *
     * @param maxSize the maximum size of the cache in bytes.
     * @param maxLifetime the maximum amount of time objects can exist in
     *    cache before being deleted.
     */
    public Cache(int maxSize, long maxLifetime) {
        this();
        this.maxSize = maxSize;
        this.maxLifetime = maxLifetime;
    }

    /**
     * Returns the current size of the cache in bytes.
     *
     * @return the size of the cache in bytes.
     */
    public int getSize() {
        return size;
    }

    /**
     * Returns 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.
     *
     * @return the maximum size of the cache in bytes.
     */
    public int getMaxSize() {
        return maxSize;
    }

    /**
     * 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.
     *

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91免费国产在线| 日韩免费一区二区| 91麻豆精品国产自产在线观看一区| 欧美一二三区在线观看| 成人欧美一区二区三区小说 | 精品成人免费观看| 亚洲国产高清在线| 久久国产精品色婷婷| 91视频国产观看| 久久久久久久精| 美女一区二区视频| 欧美日韩一级二级三级| 国产精品高潮呻吟久久| 国产麻豆一精品一av一免费| 欧美三级日韩三级| 亚洲男人天堂av| 粉嫩av一区二区三区粉嫩| 欧美电影免费观看高清完整版在线观看 | 国产亚洲一区二区在线观看| 亚洲成人黄色小说| 色一区在线观看| 亚洲色图视频免费播放| 国产成人av在线影院| 欧美不卡123| 另类人妖一区二区av| 欧美一区二区日韩一区二区| 亚洲一区二区三区美女| 波多野结衣在线aⅴ中文字幕不卡| 欧美一级电影网站| 毛片av一区二区| 欧美一级在线视频| 免费视频一区二区| 日韩限制级电影在线观看| 日韩成人精品在线| 欧美日韩国产一二三| 亚洲一区二区三区激情| 欧美在线观看视频在线| 亚洲影视在线播放| 欧美高清一级片在线| 免费高清不卡av| 精品91自产拍在线观看一区| 国产一区二区剧情av在线| 国产午夜亚洲精品午夜鲁丝片 | 国产日本亚洲高清| 国产福利精品一区| 国产精品国产精品国产专区不蜜| 99免费精品在线| 一区二区三区国产精品| 欧美在线视频你懂得| 午夜精品在线视频一区| 欧美成人激情免费网| 国产成人aaaa| ...av二区三区久久精品| 欧美在线三级电影| 日韩激情一区二区| 久久精品视频一区二区| 色综合中文字幕| 日韩av一二三| 国产亚洲污的网站| 在线观看免费一区| 国产一区二区在线电影| 亚洲天堂网中文字| 3d动漫精品啪啪| 国产精品乡下勾搭老头1| 亚洲天堂2016| 精品国产在天天线2019| 成人午夜大片免费观看| 午夜精品福利在线| 欧美经典一区二区| 欧美猛男男办公室激情| 成人一区二区三区中文字幕| 亚洲一区二区视频在线观看| 日韩视频一区二区在线观看| 成人免费毛片高清视频| 日韩精品福利网| 欧美国产精品专区| 欧美成人女星排名| 在线中文字幕不卡| 国产大陆精品国产| 婷婷夜色潮精品综合在线| 中文在线一区二区| 日韩午夜在线观看| 色婷婷久久久综合中文字幕| 国产精品一级片在线观看| 亚洲午夜成aⅴ人片| 国产精品素人视频| 精品电影一区二区三区| 欧美午夜片在线观看| 成人午夜视频在线观看| 老司机一区二区| 午夜视黄欧洲亚洲| 亚洲欧美视频在线观看| 国产亚洲一区二区三区在线观看| 欧美一区二区三区免费在线看| 91污在线观看| 成人午夜视频在线| 国产米奇在线777精品观看| 日韩精品一卡二卡三卡四卡无卡| 亚洲靠逼com| 中文字幕欧美激情一区| 精品国产一区二区三区av性色| 欧美日本国产视频| 欧美体内she精高潮| 91麻豆国产福利精品| 岛国精品一区二区| 成人性视频网站| 国产suv精品一区二区883| 国产一区二区日韩精品| 久久国产精品区| 蜜乳av一区二区三区| 日韩—二三区免费观看av| 日韩中文字幕区一区有砖一区| 亚洲综合丝袜美腿| 性感美女极品91精品| 亚洲国产精品久久一线不卡| 亚洲精品成a人| 亚洲午夜精品17c| 亚洲国产另类精品专区| 五月婷婷久久丁香| 日韩1区2区日韩1区2区| 麻豆专区一区二区三区四区五区| 奇米亚洲午夜久久精品| 免费观看成人av| 九九精品视频在线看| 韩日欧美一区二区三区| 国产制服丝袜一区| 国产美女在线精品| 99在线热播精品免费| 在线一区二区观看| 在线播放亚洲一区| 精品少妇一区二区三区视频免付费 | 成人av免费在线观看| 成人激情免费视频| 色婷婷亚洲精品| 欧美一区二区三区四区在线观看| 日韩三级.com| 久久久精品2019中文字幕之3| 欧美国产日韩a欧美在线观看 | 国产精品灌醉下药二区| 一区二区三区不卡视频在线观看| 亚洲午夜精品久久久久久久久| 青椒成人免费视频| 国产91精品免费| 欧美精品久久99| 久久久久久久久久久久电影| 国产精品传媒视频| 午夜视频久久久久久| 国产精品99久久久久久宅男| 成人精品免费视频| 欧美喷潮久久久xxxxx| 2020国产精品| 夜夜揉揉日日人人青青一国产精品| 亚洲一区二区三区精品在线| 免费人成在线不卡| 99国产精品久久久| 日韩欧美国产综合一区| 亚洲人快播电影网| 狠狠网亚洲精品| 欧美日韩一区二区欧美激情 | 亚洲成av人在线观看| 国产老肥熟一区二区三区| 91黄色免费观看| 国产拍揄自揄精品视频麻豆| 亚洲一区二区三区四区的| 国产高清无密码一区二区三区| 欧美美女黄视频| 中文字幕一区在线观看| 激情文学综合插| 欧美高清dvd| 一区二区三区中文字幕电影| 国产自产视频一区二区三区| 欧美精品亚洲一区二区在线播放| 成人免费一区二区三区视频 | 蜜桃在线一区二区三区| 色综合视频一区二区三区高清| 欧美不卡一区二区三区| 亚洲国产成人av网| 成人av第一页| 久久色视频免费观看| 三级影片在线观看欧美日韩一区二区| 国产福利91精品一区二区三区| 欧美在线你懂的| 日韩美女视频一区二区 | 免费观看久久久4p| 欧美在线综合视频| 亚洲视频在线一区| 成人性生交大片免费看中文| 日韩视频在线一区二区| 午夜激情一区二区三区| 色婷婷精品久久二区二区蜜臂av | 26uuuu精品一区二区| 日日嗨av一区二区三区四区| 欧美性大战久久| 亚洲成人中文在线| 欧美日韩在线播放三区四区| 亚洲乱码日产精品bd| 91在线云播放| 国产精品久久久久久久久免费丝袜 | 豆国产96在线|亚洲| 国产日韩欧美电影|