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

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

?? cache.java

?? jive 論壇所有的java源碼
?? 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 ;
    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.
     *

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
自拍偷拍国产亚洲| 亚洲精品老司机| 亚洲成人免费av| 国产乱国产乱300精品| 欧美性一级生活| 国产日韩三级在线| 日韩中文字幕区一区有砖一区| 精品亚洲免费视频| 欧美三电影在线| 中文字幕色av一区二区三区| 精品一区二区三区香蕉蜜桃 | 精品制服美女丁香| 欧美无乱码久久久免费午夜一区| 国产午夜久久久久| 蜜臀va亚洲va欧美va天堂| 日本高清视频一区二区| 欧美激情在线看| 国精产品一区一区三区mba视频| 欧美群妇大交群的观看方式| 亚洲免费在线看| 99在线精品一区二区三区| 国产日韩精品一区二区三区在线| 久久精品国产99国产| 欧美久久一区二区| 日韩国产欧美一区二区三区| 在线精品亚洲一区二区不卡| 亚洲啪啪综合av一区二区三区| 国产成人三级在线观看| 国产亚洲欧美色| 国产91精品免费| 日本一区二区三区电影| 成人美女在线视频| 亚洲欧洲一区二区在线播放| 成av人片一区二区| 日韩av电影天堂| 在线91免费看| 麻豆91精品91久久久的内涵| 91精品久久久久久久91蜜桃| 日本欧洲一区二区| 亚洲精品在线免费播放| 九九精品一区二区| 国产精品三级在线观看| 91在线无精精品入口| 伊人色综合久久天天| 欧美日韩和欧美的一区二区| 日韩国产精品久久久| 日韩女优制服丝袜电影| 国产久卡久卡久卡久卡视频精品| 中文幕一区二区三区久久蜜桃| 99国内精品久久| 亚洲电影一级片| 欧美成人r级一区二区三区| 精品影视av免费| 亚洲日本在线看| 欧美挠脚心视频网站| 精品一区二区精品| 成人免费小视频| 3d成人动漫网站| 国产丶欧美丶日本不卡视频| **性色生活片久久毛片| 欧美浪妇xxxx高跟鞋交| 国产精品一区二区男女羞羞无遮挡| 日韩久久一区二区| 91精品国产综合久久国产大片| 国产美女av一区二区三区| 国产精品久久免费看| 欧美综合在线视频| 国产在线精品视频| 亚洲精品免费在线观看| 精品欧美一区二区在线观看| 99久久99久久综合| 美女任你摸久久| 亚洲三级久久久| 精品国产麻豆免费人成网站| 91啪亚洲精品| 国产99久久久国产精品免费看| 亚洲一级电影视频| 国产精品久久久久久久久免费丝袜| 欧美日韩aaa| 国产伦精品一区二区三区免费迷| 亚洲自拍都市欧美小说| 久久一夜天堂av一区二区三区| 91黄色激情网站| 成人午夜视频免费看| 日本欧美肥老太交大片| 亚洲精品亚洲人成人网在线播放| 精品国产亚洲在线| 欧美日韩第一区日日骚| 丰满放荡岳乱妇91ww| 免费看日韩a级影片| 专区另类欧美日韩| 久久精子c满五个校花| 日韩精品一区二区三区视频| 欧美色图激情小说| 91毛片在线观看| 成人av在线电影| 国产另类ts人妖一区二区| 日韩av网站在线观看| 亚洲第一成年网| 亚洲综合免费观看高清完整版在线| 国产日产欧美一区| 久久久久久免费毛片精品| 欧美一区二区日韩一区二区| 欧美色精品天天在线观看视频| 91小宝寻花一区二区三区| 成人午夜激情在线| 高清国产一区二区| 丁香一区二区三区| 粉嫩av一区二区三区在线播放| 国产做a爰片久久毛片| 激情综合网av| 激情小说亚洲一区| 精久久久久久久久久久| 激情亚洲综合在线| 国产激情一区二区三区四区| 国产精品亚洲一区二区三区妖精| 精品一区二区三区影院在线午夜| 久久成人羞羞网站| 精品一二三四区| 风间由美一区二区av101| 国产精品一二三在| 不卡视频在线看| 色婷婷av一区二区三区软件 | 国产.欧美.日韩| 国产成人综合视频| 国产精品影音先锋| 成人国产精品免费观看视频| 99视频精品在线| 精品视频在线看| 欧美一级视频精品观看| 精品国产乱码久久久久久闺蜜| 久久亚洲精精品中文字幕早川悠里| 久久你懂得1024| 一区视频在线播放| 亚洲国产精品一区二区久久| 青青草97国产精品免费观看| 国产麻豆精品久久一二三| 福利一区在线观看| 色屁屁一区二区| 91精品免费在线| 国产欧美日韩中文久久| 亚洲一区日韩精品中文字幕| 午夜精品久久久久久久久久| 久久99国产精品麻豆| 成人黄色一级视频| 欧美精品第1页| 国产亚洲午夜高清国产拍精品| 亚洲人精品一区| 麻豆成人免费电影| 99久久综合国产精品| 在线不卡免费欧美| 欧美国产精品劲爆| 日韩专区中文字幕一区二区| 国产精品中文有码| 欧美伦理电影网| 国产精品美日韩| 看片网站欧美日韩| 91啪九色porn原创视频在线观看| 91精品国产综合久久香蕉的特点| 国产女主播在线一区二区| 亚洲成人福利片| 99久久精品免费| 精品免费日韩av| 亚洲电影在线免费观看| 成人午夜av在线| 日韩美女视频一区二区在线观看| 国产精品二三区| 激情久久五月天| 7777精品伊人久久久大香线蕉的 | 欧美色图激情小说| 国产精品每日更新| 精品一区二区三区免费播放| 欧美中文字幕久久| 国产精品久久久久精k8 | 欧美午夜影院一区| 国产三区在线成人av| 人人狠狠综合久久亚洲| 色综合天天狠狠| 国产精品女人毛片| 国产精品自拍三区| 欧美精品一区二区在线播放| 日韩中文字幕91| 欧美日韩中文国产| 亚洲黄色小视频| 色综合天天综合给合国产| 亚洲精品一区二区三区香蕉| 免费成人美女在线观看.| 欧美日韩一区二区三区在线| 亚洲男人的天堂在线观看| 处破女av一区二区| 国产天堂亚洲国产碰碰| 国产a久久麻豆| 中文字幕高清不卡| 成人综合在线视频| 国产精品美女久久久久久久久久久| 国产精品1区2区| 久久久www成人免费毛片麻豆| 极品美女销魂一区二区三区免费| 日韩一区二区免费在线观看| 蜜臀av一区二区在线观看|