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

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

?? cache.java

?? jive Study
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/**
 * $RCSfile: Cache.java,v $
 * $Revision: 1.2 $
 * $Date: 2000/12/21 17:47:20 $
 *
 * Copyright (C) 2000 CoolServlets.com. All rights reserved.
 *
 * ===================================================================
 * The Apache Software License, Version 1.1
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by
 *        CoolServlets.com (http://www.Yasna.com)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Jive" and "CoolServlets.com" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please
 *    contact webmaster@Yasna.com.
 *
 * 5. Products derived from this software may not be called "Jive",
 *    nor may "Jive" appear in their name, without prior written
 *    permission of CoolServlets.com.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL COOLSERVLETS.COM OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of CoolServlets.com. For more information
 * on CoolServlets.com, please see <http://www.Yasna.com>.
 */

package com.Yasna.util;

import java.util.*;
import com.Yasna.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 = System.currentTimeMillis();

    /**
     * A cache timer updates the current time once a second in a seperate
     * thread.
     */
    protected static CacheTimer timer = new CacheTimer(1000L);

    /**
     * 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;
    }

    /**

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲国产精品一区二区尤物区| caoporn国产一区二区| 国产精品白丝jk白祙喷水网站 | 九九国产精品视频| 成人av电影在线网| 日韩免费性生活视频播放| 自拍偷拍欧美激情| 国产精品一区二区在线观看不卡| 欧美性感一区二区三区| 欧美激情一区二区三区四区| 美国十次了思思久久精品导航| 色国产综合视频| 国产嫩草影院久久久久| 久久成人av少妇免费| 欧美日韩精品一区二区在线播放| 最好看的中文字幕久久| 国产高清不卡一区| 欧美变态tickling挠脚心| 亚洲午夜在线电影| 在线观看日韩电影| 亚洲欧美日韩综合aⅴ视频| 国产成人免费9x9x人网站视频| 欧美xxxx在线观看| 奇米一区二区三区| 制服丝袜国产精品| 日本不卡1234视频| 日韩一区二区免费在线观看| 天堂va蜜桃一区二区三区漫画版| 精品视频一区二区不卡| 亚洲国产综合91精品麻豆| 欧美中文字幕一区| 一区二区久久久久久| 在线一区二区观看| 亚洲午夜久久久久久久久久久| 在线看国产日韩| 亚洲成人动漫av| 欧美精品一二三区| 久久黄色级2电影| 久久蜜臀精品av| 成人午夜激情片| 亚洲丝袜制服诱惑| 欧美色网一区二区| 奇米精品一区二区三区在线观看| 91麻豆精品国产91久久久| 免费xxxx性欧美18vr| 欧美精品一区二区在线观看| 在线观看成人小视频| 亚洲va韩国va欧美va| 日韩区在线观看| 国产精品一区专区| 亚洲欧美怡红院| 欧美日韩精品一区二区| 久久国产福利国产秒拍| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 自拍偷自拍亚洲精品播放| 在线视频你懂得一区二区三区| 午夜精品福利在线| 久久久精品2019中文字幕之3| 成人午夜伦理影院| 亚洲成av人片观看| 国产欧美日韩三级| 欧美色图片你懂的| 国产美女av一区二区三区| 综合自拍亚洲综合图不卡区| 555www色欧美视频| 国产a久久麻豆| 天天影视涩香欲综合网| 国产亚洲女人久久久久毛片| 在线欧美日韩精品| 国产一区在线观看麻豆| 亚洲免费观看高清完整版在线 | 中日韩av电影| 91麻豆精品国产91久久久久久 | 亚洲精品菠萝久久久久久久| 日韩欧美高清dvd碟片| 99精品欧美一区二区三区综合在线| 日韩av中文在线观看| 亚洲国产经典视频| 欧美一区在线视频| 日本高清免费不卡视频| 国产精品1024久久| 美女视频一区在线观看| 亚洲综合免费观看高清完整版在线| 精品久久久久久久久久久久包黑料| 91美女在线观看| 国产激情精品久久久第一区二区| 调教+趴+乳夹+国产+精品| 中文字幕在线免费不卡| 久久久影院官网| 91精品国产一区二区三区| 91久久精品国产91性色tv| 高清国产午夜精品久久久久久| 美女性感视频久久| 午夜视频在线观看一区| 一区二区三区不卡在线观看| 国产精品亲子乱子伦xxxx裸| 亚洲精品在线网站| 日韩欧美国产一区在线观看| 在线播放中文一区| 欧美日韩一级黄| 在线观看亚洲精品| 色丁香久综合在线久综合在线观看| 成人av电影免费观看| 国产成人综合亚洲91猫咪| 精品中文字幕一区二区 | 一区二区成人在线| 亚洲人精品午夜| 一区二区三区蜜桃网| 亚洲欧美偷拍三级| 成人欧美一区二区三区在线播放| 久久精品国产成人一区二区三区| 亚洲不卡av一区二区三区| 亚洲国产你懂的| 日本一区中文字幕| 美女网站在线免费欧美精品| 久久精品国产免费| 国产美女精品人人做人人爽| 国产麻豆一精品一av一免费| 国产精品一区二区视频| 国产福利视频一区二区三区| 风流少妇一区二区| www.欧美日韩国产在线| 色综合天天视频在线观看| 色欧美乱欧美15图片| 欧美色综合久久| 日韩欧美激情一区| 国产免费观看久久| 亚洲激情在线播放| 亚洲.国产.中文慕字在线| 免费在线视频一区| 国产一区二区按摩在线观看| 成人免费看视频| 欧美色网站导航| 久久亚洲捆绑美女| 亚洲婷婷在线视频| 奇米精品一区二区三区四区| 国产精品中文字幕一区二区三区| 粉嫩绯色av一区二区在线观看| 91在线精品一区二区| 欧美精品三级在线观看| 久久婷婷色综合| 亚洲免费观看视频| 久久99精品久久久久久国产越南| 成人高清视频在线观看| 欧美日本免费一区二区三区| 久久久久免费观看| 一区二区在线观看视频| 麻豆91在线播放| 色婷婷国产精品久久包臀 | 亚洲日本在线天堂| 免费一区二区视频| 91美女蜜桃在线| 久久婷婷国产综合国色天香| 亚洲免费在线视频| 理论电影国产精品| 91视频观看视频| 1区2区3区精品视频| 婷婷久久综合九色综合伊人色| 日韩成人午夜精品| 久久国产精品99久久人人澡| 91视频你懂的| 久久久www成人免费无遮挡大片| 亚洲综合色婷婷| 成人app在线| 亚洲精品一区二区三区蜜桃下载 | 欧美美女一区二区| 中文字幕免费在线观看视频一区| 首页亚洲欧美制服丝腿| 91丝袜美腿高跟国产极品老师 | 国产精品毛片久久久久久久| 日韩精品电影一区亚洲| 91麻豆.com| 中文字幕欧美日韩一区| 精品一区二区三区免费| 欧美另类高清zo欧美| 亚洲免费高清视频在线| 成人激情电影免费在线观看| 精品久久久网站| 麻豆精品久久久| 欧美另类变人与禽xxxxx| 一级做a爱片久久| av资源网一区| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 不卡的av中国片| 久久在线免费观看| 韩国一区二区视频| 日韩你懂的在线播放| 蜜桃av噜噜一区二区三区小说| 久久久久国产一区二区三区四区| 日韩国产在线一| 777a∨成人精品桃花网| 午夜日韩在线观看| 在线成人小视频| 日本少妇一区二区| 欧美一级日韩一级| 免费不卡在线观看| 欧美成人艳星乳罩| 国产美女精品一区二区三区| 国产日韩欧美综合在线| 高潮精品一区videoshd|