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

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

?? longcache.java

?? 使用jsp和servlet開發的論壇
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/**
 * $RCSfile: LongCache.java,v $
 * $Revision: 1.1.1.1 $
 * $Date: 2002/09/09 13:51:12 $
 *
 * 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.LongLinkedList;

/**
 * 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 LongCache 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 LongHashMap cachedObjectsHash;

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

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

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

    /**
     * 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 LongCache() {
        // Our primary data structure is a hash map.
        cachedObjectsHash = new LongHashMap();

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

    /**
     * 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 LongCache(int maxSize) {
        this();
        this.maxSize = maxSize;
        this.maxObjectSize = (int)(maxSize * .9);
    }

    /**
     * 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 LongCache(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 LongCache(int maxSize, long maxLifetime) {
        this();
        this.maxSize = maxSize;
        this.maxObjectSize = (int)(maxSize * .9);
        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;
        this.maxObjectSize = (int)(maxSize * .9);
        // 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();
    }

    /**

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产曰批免费观看久久久| 国产日韩欧美精品一区| 欧美一级国产精品| 国产精品久久夜| 精品中文字幕一区二区| 在线欧美日韩国产| 国产精品不卡视频| 国产精品亚洲人在线观看| 欧美顶级少妇做爰| 亚洲精选在线视频| 亚洲欧美日韩综合aⅴ视频| 欧美国产丝袜视频| 亚洲少妇30p| 日韩av中文字幕一区二区| 久久国产尿小便嘘嘘尿| 国产成人精品免费网站| 91丨国产丨九色丨pron| 日本一区二区三区高清不卡| 日本一区二区视频在线观看| 在线一区二区视频| 26uuu成人网一区二区三区| 日韩高清在线电影| 欧美四级电影在线观看| 亚洲精品国产一区二区三区四区在线 | 欧美电视剧免费观看| 亚洲午夜影视影院在线观看| 在线观看日韩av先锋影音电影院| 亚洲视频香蕉人妖| 色综合色综合色综合色综合色综合 | 夜夜爽夜夜爽精品视频| 91网页版在线| 亚洲综合久久久| 久久激情五月婷婷| 久久精品国产77777蜜臀| 91网站最新网址| 一区二区三区日韩精品视频| 九九久久精品视频| 在线日韩一区二区| 久久久久国产精品人| 亚洲图片欧美综合| av一区二区三区| 精品sm在线观看| 91网站最新地址| 337p粉嫩大胆色噜噜噜噜亚洲| 亚洲精选视频免费看| 国产麻豆精品95视频| 欧美色成人综合| 综合激情成人伊人| 国产精品99久久久| 精品国产一区久久| 不卡一区中文字幕| 99久久精品免费看国产免费软件| 久久免费精品国产久精品久久久久| 国产999精品久久久久久| 国产精品夫妻自拍| 7777精品伊人久久久大香线蕉完整版 | 欧美主播一区二区三区| 日韩va亚洲va欧美va久久| 久久天堂av综合合色蜜桃网| 91最新地址在线播放| 亚洲午夜久久久久中文字幕久| 日韩午夜电影在线观看| eeuss鲁片一区二区三区在线观看 eeuss鲁片一区二区三区在线看 | 欧美日免费三级在线| 色av成人天堂桃色av| 日韩一区二区高清| 蜜芽一区二区三区| 91精品国产日韩91久久久久久| 亚洲欧美欧美一区二区三区| 国产精品综合av一区二区国产馆| 精品区一区二区| 91麻豆国产香蕉久久精品| 日韩精品乱码免费| 中文字幕在线观看一区二区| 日韩色在线观看| 一本久久a久久精品亚洲| 欧美写真视频网站| 国产美女娇喘av呻吟久久| 亚洲图片一区二区| 国产精品毛片大码女人| 日韩精品中文字幕在线不卡尤物| 一本到不卡免费一区二区| 国内精品久久久久影院一蜜桃| 一区二区三区四区国产精品| 国产亚洲一区字幕| 日韩欧美一二区| 日韩美女视频一区二区| 久久综合资源网| 884aa四虎影成人精品一区| 色综合久久久久久久久久久| 国产精品 欧美精品| 日本在线观看不卡视频| 亚洲最大色网站| 一区在线观看免费| 国产精品色婷婷久久58| 久久综合色婷婷| 亚洲午夜一区二区| 亚洲欧美视频一区| 国产精品第五页| 国产精品嫩草影院com| 精品国产sm最大网站免费看| 91精品麻豆日日躁夜夜躁| 欧美日韩一区二区在线观看视频| 92精品国产成人观看免费 | 国产精品国产三级国产a | 56国语精品自产拍在线观看| 色哦色哦哦色天天综合| 国产欧美久久久精品影院| 国产揄拍国内精品对白| 亚洲精品伦理在线| 精品国产乱码久久久久久久| 色综合天天综合色综合av| 不卡一区二区三区四区| 石原莉奈在线亚洲三区| 中文字幕成人av| 日韩一区二区免费电影| 91极品视觉盛宴| 国产成人精品免费| 久久久久久久综合| 一区二区久久久久| 亚洲一二三四久久| 日日摸夜夜添夜夜添亚洲女人| 日本伊人精品一区二区三区观看方式| 三级久久三级久久久| 久久99精品久久久久婷婷| 国内成人免费视频| 波波电影院一区二区三区| 97精品久久久午夜一区二区三区| 91蜜桃免费观看视频| 亚洲三级在线观看| 亚洲国产综合色| 日韩在线播放一区二区| 国产曰批免费观看久久久| av日韩在线网站| 欧美日韩情趣电影| 久久先锋影音av鲁色资源网| 国产精品视频在线看| 日韩视频一区二区三区在线播放| 欧美精品在线观看一区二区| 色综合久久中文综合久久97| voyeur盗摄精品| 大尺度一区二区| 国产成人亚洲综合a∨猫咪| 老司机精品视频一区二区三区| 午夜激情一区二区| 五月激情综合婷婷| 日本中文字幕一区| 蜜桃视频第一区免费观看| 成人免费视频一区| 国产成人午夜片在线观看高清观看| 久热成人在线视频| 国精品**一区二区三区在线蜜桃| 免费观看在线色综合| 蜜臀av性久久久久av蜜臀妖精| 午夜电影网一区| 日本大胆欧美人术艺术动态| 日韩二区三区四区| 美女网站色91| 欧美电影在哪看比较好| 91麻豆精品国产91久久久久久久久| 7777精品伊人久久久大香线蕉经典版下载| 欧美吻胸吃奶大尺度电影| 国模大尺度一区二区三区| 国产成人亚洲综合色影视| 欧美精品第1页| 自拍偷拍亚洲综合| 国产九色精品成人porny| 欧美老年两性高潮| 亚洲精品亚洲人成人网在线播放| 久久疯狂做爰流白浆xx| 欧美日韩另类国产亚洲欧美一级| 国产精品女主播在线观看| 国产在线播放一区三区四| 欧美精品丝袜中出| 亚洲国产精品一区二区久久| jlzzjlzz欧美大全| 国产午夜三级一区二区三| 日本成人中文字幕| 欧美精品色一区二区三区| 一区二区三区在线观看网站| av一本久道久久综合久久鬼色| 久久久亚洲精品一区二区三区 | 亚洲午夜久久久| 美女网站视频久久| 91免费在线看| 日韩精品一区二区三区中文精品| 国产精品久久午夜夜伦鲁鲁| 午夜精品久久久久久久久久| 黄色成人免费在线| 欧美午夜精品久久久| 成人影视亚洲图片在线| 日韩一区二区三区视频在线观看| 午夜激情久久久| 9191成人精品久久| 日韩av网站免费在线| 日韩一级成人av| 久久国产精品一区二区| 精品处破学生在线二十三| 激情欧美日韩一区二区| 精品福利二区三区|