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

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

?? cache.java

?? Jvie論壇的程序
?? 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一区二区三区免费野_久草精品视频
国产精品久久久久久久久动漫| 欧美日韩小视频| 国产精品久久综合| 成人午夜视频在线| 亚洲色图在线播放| 日本高清成人免费播放| 一区二区成人在线观看| 欧美人伦禁忌dvd放荡欲情| 丝袜脚交一区二区| 欧美成人精品福利| 高清不卡在线观看av| 亚洲欧美日韩综合aⅴ视频| 欧美视频一区在线观看| 日本成人中文字幕| 久久久精品日韩欧美| 91麻豆免费视频| 天天综合色天天| 日本一区二区三区久久久久久久久不| av一区二区三区四区| 亚洲成人高清在线| 精品国产一区二区在线观看| www.亚洲国产| 石原莉奈在线亚洲二区| 日本一区二区三区四区| 色婷婷亚洲精品| 久久精品av麻豆的观看方式| 国产精品高潮呻吟| 91精品欧美福利在线观看| 成人中文字幕电影| 午夜av一区二区三区| 国产欧美一区二区在线观看| 欧洲精品中文字幕| 国产精品18久久久久久久久久久久| 亚洲少妇中出一区| 精品国产乱码久久久久久久 | 水野朝阳av一区二区三区| 26uuu精品一区二区三区四区在线| 91在线看国产| 狠狠色丁香久久婷婷综合丁香| 一区二区三区av电影| 久久久亚洲精品一区二区三区| 在线一区二区三区四区| 国产乱人伦偷精品视频不卡| 丝袜美腿亚洲色图| 一区二区三区日韩欧美| 国产日韩欧美综合一区| 7777精品伊人久久久大香线蕉 | 久久久影视传媒| 欧美精品在线观看一区二区| 成人午夜免费电影| 美女视频网站黄色亚洲| 午夜天堂影视香蕉久久| 综合久久综合久久| 日本一区二区视频在线观看| 欧美大片一区二区| 555www色欧美视频| 欧美色成人综合| 91蝌蚪porny九色| 国产91丝袜在线18| 国产一区二区三区免费| 久久精品99国产精品| 人人精品人人爱| 丝瓜av网站精品一区二区 | 不卡欧美aaaaa| 国产99久久久精品| 狠狠色综合日日| 乱中年女人伦av一区二区| 亚洲成av人片在线观看| 亚洲一区二区视频| 依依成人精品视频| 亚洲一区二区欧美| 亚洲主播在线观看| 亚洲成人一区二区在线观看| 亚洲一区视频在线观看视频| 亚洲一区二区在线视频| 亚洲国产日日夜夜| 日韩影院在线观看| 琪琪久久久久日韩精品| 蜜臀a∨国产成人精品| 免费日韩伦理电影| 国内成人精品2018免费看| 久久国产精品99精品国产| 激情六月婷婷久久| 国产传媒欧美日韩成人| 成人激情免费视频| kk眼镜猥琐国模调教系列一区二区| 懂色av中文一区二区三区| 成人看片黄a免费看在线| av午夜一区麻豆| 91首页免费视频| 欧美日韩一区二区三区在线看 | 国产欧美日韩三区| 国产精品免费网站在线观看| 一区精品在线播放| 亚洲国产精品麻豆| 日韩av在线播放中文字幕| 麻豆91小视频| 99re在线视频这里只有精品| 在线免费观看一区| 国产一区二区不卡| 26uuu欧美日本| 2023国产精品视频| 老司机精品视频在线| 精品第一国产综合精品aⅴ| 99久久久久久| 高清免费成人av| 欧美色图在线观看| 精品成人一区二区| 亚洲人精品一区| 日本欧美一区二区三区| 国产成+人+日韩+欧美+亚洲| 欧美在线观看禁18| 久久久久久免费网| 亚洲一区二区三区四区在线免费观看| 老司机午夜精品| 北岛玲一区二区三区四区| 国产成人在线网站| 精品制服美女久久| 91免费视频网址| 欧美成人欧美edvon| 国产精品久久久久久久久晋中| 日韩高清在线电影| 97久久久精品综合88久久| 欧美精品xxxxbbbb| 最新国产精品久久精品| 韩国欧美国产1区| 欧美日韩在线播放三区四区| 国产欧美一区在线| 奇米色一区二区| 色婷婷av一区二区三区大白胸 | 久久久www成人免费毛片麻豆| 日韩欧美国产三级| 国产精品久久网站| 久久av中文字幕片| 欧美专区日韩专区| 国产精品久久久久久久久免费丝袜 | 最新日韩在线视频| 国产一区二区三区观看| 在线观看91av| 亚洲成人1区2区| 在线视频你懂得一区| 国产精品视频一二三| 美女视频一区在线观看| 欧美日韩高清影院| 亚洲精品中文在线| www.日韩精品| 国产精品美日韩| 国产盗摄视频一区二区三区| 91精品国产黑色紧身裤美女| 亚洲亚洲人成综合网络| 99久精品国产| 最新久久zyz资源站| 国产乱妇无码大片在线观看| 日韩欧美一区电影| 日本怡春院一区二区| 在线成人免费观看| 亚洲观看高清完整版在线观看| 一本大道久久a久久综合婷婷| 中文字幕免费在线观看视频一区| 狠狠色狠狠色综合日日91app| 精品国产免费人成在线观看| 蜜桃av一区二区在线观看| 91麻豆精品91久久久久同性| 午夜欧美视频在线观看| 欧美日韩国产中文| 五月激情综合色| 欧美精三区欧美精三区| 日韩精品色哟哟| 日韩欧美中文字幕精品| 日韩精品一二三| 日韩一本二本av| 国产一区二区三区观看| 国产欧美日韩不卡免费| 粉嫩久久99精品久久久久久夜| 国产欧美一区二区三区网站| 成人视屏免费看| 玉足女爽爽91| 欧美美女黄视频| 美脚の诱脚舐め脚责91| 精品国产91洋老外米糕| 国产成人在线视频免费播放| 国产精品私人影院| 一本在线高清不卡dvd| 亚洲自拍另类综合| 日韩欧美三级在线| 国产成人午夜高潮毛片| 中文字幕日本不卡| 欧美日韩一区二区在线观看视频| 免费成人在线视频观看| 国产欧美一区二区精品婷婷| 99热精品国产| 日韩高清电影一区| 久久久五月婷婷| 色综合久久天天综合网| 天天综合色天天| 国产亚洲精品aa| 欧美日韩一级片在线观看| 国产一区二区美女| 亚洲综合区在线| 欧美精品一区二区三区视频|