亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
色噜噜狠狠色综合欧洲selulu| 国产精品18久久久久| 欧美高清在线视频| 日韩欧美国产一区在线观看| 678五月天丁香亚洲综合网| 91国偷自产一区二区使用方法| 99久久免费精品高清特色大片| 国产不卡免费视频| 91网站在线播放| 日本道免费精品一区二区三区| 色婷婷久久综合| 欧美日韩亚洲另类| 日韩一区二区在线看片| 久久久午夜精品| 国产精品第四页| 亚洲天堂2016| 日韩精品亚洲一区| 国产精品自拍av| 91丝袜美腿高跟国产极品老师| 91福利精品第一导航| 欧美日韩精品福利| 久久久国产精品麻豆| 亚洲欧洲日产国产综合网| 亚洲伊人色欲综合网| 日本亚洲欧美天堂免费| 国产ts人妖一区二区| 在线观看一区不卡| 日韩三级视频在线看| 国产精品久久午夜| 午夜在线电影亚洲一区| 国产成人自拍高清视频在线免费播放| 国内成+人亚洲+欧美+综合在线| 国产成人亚洲综合色影视| 日本韩国一区二区三区| 日韩欧美在线123| 最近日韩中文字幕| 韩国视频一区二区| 在线观看亚洲精品| 久久久久97国产精华液好用吗| 亚洲激情校园春色| 狠狠色综合日日| 欧美日韩国产综合视频在线观看 | 五月天视频一区| 国产不卡高清在线观看视频| 欧美一区二区在线看| 一区视频在线播放| 国产一区二区三区在线看麻豆| 在线观看欧美黄色| 国产三级精品视频| 久久精品999| 欧美日韩不卡视频| 一区在线观看免费| 国产成人午夜高潮毛片| 欧美军同video69gay| 中文字幕在线不卡视频| 九九**精品视频免费播放| 在线亚洲高清视频| 亚洲欧美乱综合| 成人aaaa免费全部观看| 久久久久久久久久久久电影| 日日夜夜免费精品视频| 日本高清成人免费播放| 亚洲三级小视频| 粉嫩av一区二区三区在线播放| 欧美成人精精品一区二区频| 久草这里只有精品视频| 欧美精品丝袜久久久中文字幕| 亚洲视频精选在线| a美女胸又www黄视频久久| 中文字幕巨乱亚洲| 丁香网亚洲国际| 中文字幕av资源一区| 国产一区二区在线看| 久久精品亚洲精品国产欧美kt∨ | 国产精品一区三区| 欧美一区二区三区影视| 亚洲不卡在线观看| 欧美日韩在线亚洲一区蜜芽| 亚洲不卡一区二区三区| 欧美三级在线视频| 日韩精品电影一区亚洲| 欧美一区二区精品在线| 麻豆91在线观看| 欧美精品一区二区三区蜜桃视频| 看片网站欧美日韩| 久久久不卡影院| www.亚洲免费av| 亚洲日本在线天堂| 在线日韩一区二区| 青青草97国产精品免费观看 | 中文字幕精品综合| 91在线丨porny丨国产| 亚洲精品国产a| 欧美老女人在线| 国产一区二区不卡| 中文字幕中文在线不卡住| 色综合久久88色综合天天免费| 亚洲va欧美va国产va天堂影院| 69堂成人精品免费视频| 国产激情91久久精品导航| 亚洲欧美激情小说另类| 欧美电影一区二区三区| 国产精品99久久久久久久女警 | 欧美日韩精品一区二区三区蜜桃 | 另类欧美日韩国产在线| 国产欧美精品日韩区二区麻豆天美| 成人一区二区三区视频| 亚洲主播在线观看| 精品久久久三级丝袜| 91丝袜美腿高跟国产极品老师| 日韩精品色哟哟| 国产精品剧情在线亚洲| 91精品国产全国免费观看| 成人久久视频在线观看| 丝袜亚洲精品中文字幕一区| 久久精品一区二区三区av| 欧美综合在线视频| 国产99一区视频免费| 亚洲成a人片在线不卡一二三区| 久久欧美一区二区| 91成人免费在线视频| 国产一区二区免费在线| 亚洲成人三级小说| 亚洲国产精品成人综合色在线婷婷| 欧美午夜一区二区| 成人免费视频一区| 久久99精品国产麻豆婷婷| 亚洲一区在线观看免费观看电影高清| 国产午夜精品久久| 日韩免费成人网| 91精品国产综合久久久蜜臀粉嫩 | 欧美一卡在线观看| 91网站在线播放| 国产成人午夜电影网| 久久99精品久久久久久动态图| 亚洲五码中文字幕| 亚洲色欲色欲www| 国产欧美一区二区精品性色超碰| 欧美一区二区三区免费| 欧美酷刑日本凌虐凌虐| 欧美午夜精品久久久| 91亚洲精品久久久蜜桃| 99在线精品免费| 懂色av中文一区二区三区| 国产高清成人在线| 国产一区二区三区久久悠悠色av| 另类人妖一区二区av| 日韩高清在线观看| 日韩不卡在线观看日韩不卡视频| 婷婷久久综合九色综合伊人色| 亚洲午夜av在线| 亚洲一二三四区不卡| 亚洲一区视频在线观看视频| 亚洲欧美影音先锋| 亚洲视频 欧洲视频| 一区二区三区在线视频播放| 亚洲欧美一区二区在线观看| 亚洲手机成人高清视频| 亚洲精品少妇30p| 亚洲综合丁香婷婷六月香| 亚洲成人动漫一区| 日本欧美在线观看| 精品在线播放免费| 福利一区二区在线| 一本大道久久a久久综合婷婷 | 精品美女一区二区| 精品福利一区二区三区免费视频| 精品久久久影院| 国产精品麻豆久久久| 亚洲男人天堂一区| 日韩中文字幕一区二区三区| 精品影院一区二区久久久| 成熟亚洲日本毛茸茸凸凹| 91色乱码一区二区三区| 欧美色视频一区| 精品久久久久久最新网址| 欧美高清在线一区| 亚洲成在线观看| 国内外成人在线| 91免费视频观看| 欧美一区二区日韩一区二区| 久久精品一区四区| 亚洲午夜在线观看视频在线| 免费观看在线色综合| 不卡影院免费观看| 欧美精品xxxxbbbb| 国产免费观看久久| 无码av中文一区二区三区桃花岛| 精品一区二区免费视频| 99久久国产综合色|国产精品| 欧美精品 日韩| 国产精品日日摸夜夜摸av| 亚洲高清免费视频| 成人免费高清在线观看| 9191成人精品久久| 亚洲精品欧美综合四区| 国产精品自拍三区| 欧美精品久久久久久久多人混战 | 韩国女主播一区| 欧美视频一区二|