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

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

?? cache.java

?? 這是學(xué)習(xí)Java必須讀懂兩套源代碼
?? JAVA
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
/**
 * $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;
    }

    /**

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲成人av一区二区| 久久久午夜精品| 日韩一区二区在线观看视频 | 亚洲欧美激情插| 丝袜美腿一区二区三区| 国产精品一区在线观看你懂的| 成人综合日日夜夜| 在线观看国产一区二区| 亚洲精品在线观看视频| 亚洲欧美经典视频| 麻豆国产一区二区| 色综合av在线| 久久亚洲一级片| 亚洲福利视频一区二区| 国产精品1024| 欧美精品日韩一本| 国产精品无码永久免费888| 亚洲黄色录像片| 国产成人免费视频网站高清观看视频| 一本色道久久综合精品竹菊| 欧美成va人片在线观看| 又紧又大又爽精品一区二区| 国产一区二区久久| 欧美丝袜丝交足nylons| 中文字幕av一区二区三区| 午夜视黄欧洲亚洲| 成人精品视频一区二区三区 | 寂寞少妇一区二区三区| 91精彩视频在线观看| 久久欧美一区二区| 日精品一区二区三区| eeuss影院一区二区三区| 91精品国产综合久久福利| 中文字幕一区二区三区四区不卡 | 精品国产乱码久久久久久图片| 亚洲免费视频中文字幕| 国产精品资源网站| 91精品国产全国免费观看| 亚洲人精品午夜| 成人综合在线网站| 久久久综合视频| 日本 国产 欧美色综合| 欧美日韩免费一区二区三区| 国产精品网站在线观看| 国产一区二区三区久久久| 69av一区二区三区| 亚洲成人免费在线观看| 日本精品一区二区三区高清| 中文成人综合网| 国产精品性做久久久久久| 日韩欧美你懂的| 视频一区二区欧美| 欧美色欧美亚洲另类二区| 亚洲人成网站色在线观看| 99久久99久久精品免费观看| 久久久久久久久伊人| 激情五月激情综合网| 91精品国产福利在线观看| 午夜精品123| 欧美日韩精品是欧美日韩精品| 亚洲免费观看在线观看| 91在线看国产| 亚洲视频小说图片| 97久久超碰国产精品| 亚洲欧洲精品一区二区精品久久久| 国产精品18久久久| 中文一区二区完整视频在线观看| 国产一区二区在线视频| 久久久久99精品一区| 国内久久精品视频| 2024国产精品视频| 国产一区二区三区美女| 国产视频亚洲色图| 成人国产亚洲欧美成人综合网| 国产日韩欧美综合一区| 成人av免费在线| 亚洲色图一区二区三区| 日本久久一区二区三区| 亚洲成人tv网| 51精品秘密在线观看| 免费看日韩a级影片| 精品99一区二区| 成人性视频免费网站| 日韩一区中文字幕| 欧美性生活久久| 亚洲高清不卡在线| 日韩视频免费观看高清完整版在线观看 | 国产一区在线精品| 国产欧美日韩亚州综合| a亚洲天堂av| 亚洲精品日韩一| 欧美精品1区2区3区| 免费久久精品视频| 欧美国产乱子伦| 欧美在线一区二区三区| 蜜臀99久久精品久久久久久软件| 精品播放一区二区| 99久久精品国产观看| 亚洲成a人v欧美综合天堂| 日韩视频在线你懂得| 粉嫩av一区二区三区在线播放| 最新久久zyz资源站| 欧美日韩一区国产| 精品一区二区三区免费| 中文字幕一区二区三中文字幕| 欧美三级欧美一级| 国产乱码精品一品二品| 亚洲视频一区二区在线| 91精品婷婷国产综合久久| 国产九色sp调教91| 亚洲精品成a人| 日韩一区二区视频| 成人少妇影院yyyy| 亚洲123区在线观看| 久久免费看少妇高潮| 91黄色免费版| 国产麻豆欧美日韩一区| 一区二区三区资源| 精品美女一区二区三区| 99国产精品国产精品久久| 蜜臀久久久99精品久久久久久| 国产精品天天看| 欧美人妖巨大在线| 成人h精品动漫一区二区三区| 亚洲综合免费观看高清在线观看| 337p粉嫩大胆噜噜噜噜噜91av | 亚洲另类中文字| 日韩欧美一级片| 色视频一区二区| 国产激情视频一区二区在线观看| 性欧美疯狂xxxxbbbb| 国产精品毛片a∨一区二区三区| 欧美人牲a欧美精品| av电影天堂一区二区在线| 蜜桃视频在线一区| 亚洲综合成人网| 国产精品理论在线观看| 日韩欧美亚洲国产另类| 在线观看中文字幕不卡| 成人一道本在线| 精品一区二区久久| 五月婷婷综合在线| 亚洲欧洲制服丝袜| 国产日韩欧美麻豆| 精品免费一区二区三区| 精品视频免费看| 91丝袜国产在线播放| 国产一区二区中文字幕| 蜜臀av一区二区| 午夜免费久久看| 亚洲黄一区二区三区| 亚洲国产精品传媒在线观看| 日韩欧美成人一区二区| 欧美系列一区二区| 91丝袜美腿高跟国产极品老师| 国产成人午夜视频| 精品在线免费视频| 石原莉奈在线亚洲三区| 一区二区三区四区精品在线视频| 欧美激情在线看| 久久久久久久性| 久久综合999| 欧美成人官网二区| 精品日韩av一区二区| 欧美精品免费视频| 欧美日韩一区久久| 欧美日韩一区二区在线视频| 色综合咪咪久久| 色先锋aa成人| 在线一区二区观看| 色爱区综合激月婷婷| 91免费版pro下载短视频| 99久久免费国产| 99久久综合国产精品| 不卡一区二区三区四区| 成人免费毛片嘿嘿连载视频| 丁香婷婷深情五月亚洲| 国产成人综合亚洲91猫咪| 高清不卡在线观看| 成人激情图片网| 成人一区二区三区视频在线观看| 国产99精品视频| 成人一二三区视频| 91在线porny国产在线看| 91首页免费视频| 91高清在线观看| 欧美浪妇xxxx高跟鞋交| 8v天堂国产在线一区二区| 91精品福利在线一区二区三区| 91精品一区二区三区久久久久久| 日韩视频在线观看一区二区| 欧美xxx久久| 国产人妖乱国产精品人妖| 中文字幕高清一区| 亚洲另类春色校园小说| 亚洲大型综合色站| 蜜桃一区二区三区四区| 国产福利91精品一区二区三区| 成人v精品蜜桃久久一区| 日本高清视频一区二区|