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

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

?? cache.java

?? 這是學習Java必須讀懂兩套源代碼
?? 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一区二区三区免费野_久草精品视频
一区二区三区四区亚洲| 99re这里只有精品首页| 北条麻妃一区二区三区| 欧美狂野另类xxxxoooo| 亚洲欧美在线aaa| 日本成人中文字幕| 色综合色综合色综合色综合色综合 | 成人黄页毛片网站| 日韩欧美在线1卡| 亚洲精品视频自拍| 成人av资源在线观看| 精品国产伦一区二区三区观看方式| 亚洲精品国产a| 福利电影一区二区三区| 精品国产123| 日本成人在线一区| 欧美日韩大陆一区二区| 亚洲精品中文字幕乱码三区| 成人午夜激情在线| 久久久99精品久久| 国内偷窥港台综合视频在线播放| 91精品免费在线| 亚洲第一综合色| 色综合一区二区| 亚洲婷婷国产精品电影人久久| 国产成人福利片| 久久亚洲综合色一区二区三区 | 免费在线观看成人| 欧美日韩国产首页在线观看| 1000部国产精品成人观看| 国产成人精品免费看| 久久久久9999亚洲精品| 韩国女主播一区二区三区| 亚洲精品一区二区三区蜜桃下载 | 国产拍揄自揄精品视频麻豆| 久久99精品久久久久| 精品久久久久久无| 久久99久久99| 久久九九99视频| 国产成人一级电影| 国产精品毛片大码女人| 91免费在线看| 国产精品国产三级国产aⅴ无密码| 久久精品亚洲乱码伦伦中文 | 亚洲一区二区三区自拍| 国产高清久久久| 久久精品一区二区三区四区 | 夜夜精品视频一区二区 | 精品无码三级在线观看视频| 综合色天天鬼久久鬼色| 精品一二三四区| 欧美日韩在线播放| 人人超碰91尤物精品国产| 亚洲精品免费视频| 国产欧美日韩亚州综合| 日韩视频免费观看高清完整版在线观看 | 国产片一区二区三区| 欧美精品免费视频| 91麻豆高清视频| 国产风韵犹存在线视精品| 久久不见久久见中文字幕免费| 亚洲精品国久久99热| 国产精品成人在线观看| 久久久三级国产网站| 日韩精品中午字幕| 欧美一区午夜视频在线观看| 欧美三级乱人伦电影| 日本精品一区二区三区高清| av一区二区不卡| 99九九99九九九视频精品| 国产iv一区二区三区| 精品一区二区精品| 韩国在线一区二区| 激情亚洲综合在线| 国产精品一线二线三线| 精品一区二区av| 国产精品91一区二区| 国产一区二区三区四区在线观看| 捆绑紧缚一区二区三区视频| 日本系列欧美系列| 蜜臀av一区二区在线免费观看| 日韩电影在线观看电影| 日韩二区三区四区| 精品综合久久久久久8888| 狠狠色丁香婷婷综合| 国产一区二区精品久久99| 国产成a人亚洲精品| 99久久综合国产精品| 99精品黄色片免费大全| 91久久精品一区二区三| 欧美日韩高清一区二区三区| 欧美精品日韩一区| 日韩欧美的一区| 精品国产欧美一区二区| 欧美国产精品v| 亚洲欧美日韩国产中文在线| 亚洲成人手机在线| 久久国产人妖系列| 国产高清成人在线| 色综合中文字幕| 91精品一区二区三区在线观看| 91精品欧美久久久久久动漫| 久久蜜桃香蕉精品一区二区三区| 国产日韩欧美精品综合| 亚洲精品国产高清久久伦理二区| 亚洲资源中文字幕| 狠狠色丁香婷综合久久| 97se亚洲国产综合自在线| 91成人免费在线| 日韩一级片在线播放| 欧美激情综合五月色丁香小说| 亚洲男人天堂av| 麻豆国产精品777777在线| 波多野结衣亚洲| 欧美日产国产精品| 久久综合999| 亚洲美女区一区| 99re成人精品视频| 精品视频一区 二区 三区| 精品乱人伦小说| 亚洲欧美色图小说| 青青草国产精品97视觉盛宴 | 不卡一区二区三区四区| 在线91免费看| 国产精品久久午夜夜伦鲁鲁| 日本午夜精品视频在线观看| 北条麻妃一区二区三区| 精品免费国产二区三区| 一二三区精品视频| 国产高清视频一区| 欧美一级片在线观看| 亚洲猫色日本管| 国产成人亚洲综合a∨婷婷| 欧洲亚洲国产日韩| 国产日韩精品久久久| 日韩黄色片在线观看| hitomi一区二区三区精品| 精品国产伦理网| 亚洲高清免费视频| caoporm超碰国产精品| 久久综合九色综合97婷婷女人| 亚洲成人免费视频| 一本一道久久a久久精品综合蜜臀| ww亚洲ww在线观看国产| 午夜精品一区二区三区免费视频 | 欧美肥妇bbw| 国产精品久久久久影院亚瑟| 国产自产高清不卡| 在线播放中文一区| 亚洲一区二区五区| 99精品热视频| 国产精品天天看| 国产91精品一区二区麻豆亚洲| 日韩欧美久久久| 性做久久久久久久免费看| 色94色欧美sute亚洲线路一ni| 欧美激情一区二区三区蜜桃视频| 精品一区二区国语对白| 日韩免费观看2025年上映的电影| 亚洲午夜精品17c| 在线这里只有精品| 亚洲欧美国产77777| 99精品视频在线观看| 欧美激情一区三区| 成人污视频在线观看| 日本一区二区视频在线观看| 国产成人av电影在线| 亚洲成a天堂v人片| 欧美综合天天夜夜久久| 亚洲综合视频网| 欧美午夜宅男影院| 亚洲h精品动漫在线观看| 欧美三日本三级三级在线播放| 亚洲狠狠爱一区二区三区| 欧美亚洲愉拍一区二区| 亚洲国产wwwccc36天堂| 3751色影院一区二区三区| 日韩精品福利网| 精品国产乱码久久久久久1区2区| 久久99国产精品成人| 久久九九久精品国产免费直播| 国产高清无密码一区二区三区| 欧美国产精品久久| 91蝌蚪porny| 午夜视频久久久久久| 91精品国产色综合久久不卡电影| 青青青伊人色综合久久| 久久精品一级爱片| 91片在线免费观看| 日韩专区中文字幕一区二区| 精品国内片67194| 99精品视频中文字幕| 三级影片在线观看欧美日韩一区二区| 日韩一区二区不卡| 成人精品国产免费网站| 亚洲一区二区五区| 久久久亚洲精品石原莉奈| av色综合久久天堂av综合| 亚洲国产日韩精品| 久久久久国产精品人|