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

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

?? dbcachemanager.java

?? 這是學習Java必須讀懂兩套源代碼
?? JAVA
字號:
/**
 * Copyright (C) 2001 Yasna.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
 *        Yasna.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 "Yazd" and "Yasna.com" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please
 *    contact yazd@yasna.com.
 *
 * 5. Products derived from this software may not be called "Yazd",
 *    nor may "Yazd" appear in their name, without prior written
 *    permission of Yasna.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 YASNA.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 Yasna.com. For more information
 * on Yasna.com, please see <http://www.yasna.com>.
 */

/**
 * 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.coolservlets.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@coolservlets.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.coolservlets.com>.
 */

package com.Yasna.forum.database;

import com.Yasna.util.*;

/**
 * Central cache management of all caches used by Jive.
 */
public class DbCacheManager {

    public static int USER_CACHE = 0;
    public static int USER_ID_CACHE = 1;
    public static int GROUP_CACHE = 2;
    public static int GROUP_ID_CACHE = 3;
    public static int FORUM_CACHE = 4;
    public static int FORUM_ID_CACHE = 5;
    public static int THREAD_CACHE = 6;
    public static int MESSAGE_CACHE = 7;
    public static int USER_PERMS_CACHE = 8;

    protected Cache[] caches;

    private boolean cacheEnabled = true;

    public DbCacheManager() {
        int MINUTE = 1000*60;
        int HOUR = MINUTE*60;

        caches = new Cache[9];

        //Initialize all cache structures
        caches[USER_CACHE] = new Cache(256*1024, 6*HOUR);
        caches[USER_ID_CACHE] = new Cache(128*1024, 6*HOUR);
        caches[GROUP_CACHE] = new Cache(128*1024, 6*HOUR);
        caches[GROUP_ID_CACHE] = new Cache(128*1024, 6*HOUR);
        caches[FORUM_CACHE] = new Cache(128*1024, 6*HOUR);
        caches[FORUM_ID_CACHE] = new Cache(128*1024, 6*HOUR);
        caches[THREAD_CACHE] = new Cache(128*1024, 6*HOUR);
        caches[MESSAGE_CACHE] = new Cache(512*1024, 6*HOUR);
        //The user permissions cache is a special one. It's actually a Cache
        //of Cache objects. Each of the cache objects in the main cache
        //corresponds to a particular forum, and is used to cache the
        //permissions that a user has for a forum. In order to handle this
        //requirement, we use a special subclass of Cache.
        caches[USER_PERMS_CACHE] = new UserPermsCache(256*1024, 24*HOUR);
    }

    public Cache getCache(int cacheType) {
        return caches[cacheType];
    }

    public void add(int cacheType, Object key, Cacheable object) {
        caches[cacheType].add(key, object);
    }

    public Cacheable get(int cacheType, Object key) {
        if (!cacheEnabled) {
            return null;
        }
        return caches[cacheType].get(key);
    }

    public void remove(int cacheType, Object key) {
        caches[cacheType].remove(key);
        //when cache becomes distributed, we'd send out an expire message
        //here to all other yazd servers.
    }

    public void removeUserPerm(Object userID) {
        Object [] values  = caches[USER_PERMS_CACHE].values().toArray();
        for (int i=0; i<values.length; i++) {
            Cache cache = (Cache)((CacheObject)values[i]).object;
            cache.remove(userID);
        }
        //when cache becomes distributed, we'd send out an expire message
        //here to all other yazd servers.
    }

    public void removeUserPerm(Object userID, Object forumID) {
        Cache cache = (Cache)caches[USER_PERMS_CACHE].get(forumID);
        if (cache != null) {
            cache.remove(userID);
        }
        //when cache becomes distributed, we'd send out an expire message
        //here to all other yazd servers.
    }

    public void clear(int cacheType) {
        caches[cacheType].clear();
        //when cache becomes distributed, we'd send out an expire message
        //here to all other yazd servers.
    }

    public boolean isCacheEnabled() {
        return cacheEnabled;
    }

    public void setCacheEnabled(boolean cacheEnabled) {
        this.cacheEnabled = cacheEnabled;
    }
}

/**
 * Special purpose Cache to hold all of the different user permission cache
 * objects. The main feature is that new caches are automatically created so
 * that calling get() never returns null.
 */
class UserPermsCache extends Cache {

    public UserPermsCache(int size, long expireTime) {
        super(size, expireTime);
    }

    public synchronized Cacheable get(Object key) {
        Cache subCache = (Cache)super.get(key);
        if (subCache == null) {
            //cache has expired, or is not there, so put a new one in there.
            //Cache objects only need to last as long as a user's session
            //does. Half an hour is a reasonable amount of time for this.
            subCache = new Cache(2*1024, 30*1000*60);
            add(key, subCache);
        }
        return subCache;
    }

    public synchronized void remove(Object key) {
        CacheObject cacheObject = (CacheObject)cachedObjectsHash.get(key);
        //If the object is not in cache, stop trying to remove it.
        if (cacheObject == null) {
            return;
        }
        //remove from the hash map
        cachedObjectsHash.remove(key);
        //remove from the cache order list
        cacheObject.lastAccessedListNode.remove();
        cacheObject.ageListNode.remove();
        //remove references to linked list nodes
        cacheObject.ageListNode = null;
        cacheObject.lastAccessedListNode = null;
        //removed the object, so subtract its size from the total.
        size -= cacheObject.size;

        //Finally, clear the sub-cache to make sure memory is released.
        ((Cache)cacheObject.object).clear();
    }

    /**
     * Returns the current size in bytes of the cache. The base getSize() method
     * does not work correctly because the sub-caches are empty when we first
     * add them rather than the normal cache assumption that objects are near
     * the size that they will always be.
     *
     * @return the size of the cache in bytes.
     */
    public int getSize() {
        int size = 0;
        Object [] values  = values().toArray();
        for (int i=0; i<values.length; i++) {
            Cache cache = (Cache)values[i];
            size += cache.getSize();
        }
        return size;
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日本不卡视频| 亚洲国产毛片aaaaa无费看| 奇米一区二区三区av| 在线综合视频播放| 国产精品色眯眯| 亚洲永久免费av| 欧美性视频一区二区三区| 亚洲电影一级片| 91精品国产色综合久久不卡电影| 欧美aⅴ一区二区三区视频| 日韩欧美的一区| 成人午夜激情在线| 亚洲男人天堂一区| 欧美美女一区二区三区| 亚洲国产日产av| 精品国产髙清在线看国产毛片| 紧缚奴在线一区二区三区| 国产精品久久久久四虎| 欧美自拍丝袜亚洲| 奇米亚洲午夜久久精品| 久久午夜国产精品| av电影在线不卡| 亚洲国产裸拍裸体视频在线观看乱了| 欧美一卡二卡在线| 久久国产尿小便嘘嘘| 国产亚洲综合在线| 91国产视频在线观看| 久久精品国产99国产精品| 中文一区二区在线观看| 91搞黄在线观看| 久久99国产精品麻豆| 国产精品黄色在线观看| 欧美一区二区三级| 99v久久综合狠狠综合久久| 亚洲国产日韩av| 国产三级精品三级| 在线看国产一区| 成人性色生活片免费看爆迷你毛片| 亚洲蜜臀av乱码久久精品蜜桃| 日韩亚洲欧美一区| 成人激情视频网站| 日本午夜一区二区| 17c精品麻豆一区二区免费| 欧美麻豆精品久久久久久| 国产成人激情av| 亚洲成av人片www| 久久亚洲免费视频| 国产69精品久久777的优势| 国产精品电影一区二区三区| 蜜桃久久精品一区二区| 国产欧美久久久精品影院| 91精品国产高清一区二区三区| av不卡在线观看| 久久99精品一区二区三区三区| 欧美高清一级片在线观看| 欧美三级韩国三级日本三斤| 日本成人在线视频网站| 亚洲精品中文字幕在线观看| 成人一区二区三区在线观看 | 日韩电影在线观看网站| 欧美喷潮久久久xxxxx| 亚洲精品乱码久久久久久| 欧美日韩在线免费视频| 91麻豆swag| 久久成人久久鬼色| 伊人一区二区三区| 亚洲免费观看高清| 国产精品久线观看视频| 久久免费电影网| 国产无人区一区二区三区| 精品噜噜噜噜久久久久久久久试看| 在线播放91灌醉迷j高跟美女 | 波多野结衣在线一区| 久久不见久久见免费视频7 | 欧美日韩黄视频| 欧美日韩午夜在线| 欧美日韩国产天堂| 91精品午夜视频| 日韩欧美另类在线| 亚洲精品在线免费观看视频| 欧美大片国产精品| 精品国产91久久久久久久妲己 | 色94色欧美sute亚洲线路一ni| 不卡免费追剧大全电视剧网站| 成人污视频在线观看| 不卡av在线网| 欧美综合欧美视频| 欧美一区二区网站| 欧美变态tickling挠脚心| 欧美精品一区二区在线播放| 久久精品免费在线观看| 亚洲欧洲av一区二区三区久久| 国产精品成人免费精品自在线观看| 1000精品久久久久久久久| 亚洲黄色片在线观看| 日韩激情中文字幕| 在线播放欧美女士性生活| 成人黄色在线视频| 精品国产91亚洲一区二区三区婷婷| 欧美精选午夜久久久乱码6080| 波多野结衣欧美| 成人福利视频网站| 日日噜噜夜夜狠狠视频欧美人| 亚洲国产精品自拍| 亚洲午夜三级在线| 免费精品99久久国产综合精品| 天天综合色天天综合色h| www.66久久| 91丨porny丨首页| 欧美色大人视频| 欧美精品一区二区三| 国产精品国产三级国产aⅴ无密码 国产精品国产三级国产aⅴ原创 | 亚洲国产精品嫩草影院| 久久精品国产一区二区三| 国产suv精品一区二区883| 在线亚洲欧美专区二区| 精品久久人人做人人爱| 一区二区视频在线看| 久久精品噜噜噜成人av农村| 99精品欧美一区二区三区小说| 欧美精品在线一区二区三区| 国产精品国产三级国产三级人妇 | 中文字幕+乱码+中文字幕一区| 一区二区三区欧美| 国产一区二区在线视频| 在线免费视频一区二区| 国产日韩精品一区二区浪潮av| 一级中文字幕一区二区| 国产乱码精品一区二区三| 欧美日韩综合在线免费观看| 欧美国产成人精品| 六月丁香婷婷色狠狠久久| 日本福利一区二区| 日本一区二区三区免费乱视频| 奇米四色…亚洲| 欧美图片一区二区三区| 国产精品久久久久久久第一福利| 日韩和欧美一区二区| 色综合久久88色综合天天6| 久久久久国产精品厨房| 日本欧美在线看| 欧美视频三区在线播放| 最近日韩中文字幕| 91在线你懂得| 国产精品视频麻豆| 极品瑜伽女神91| 亚洲一区二区在线观看视频| 欧美精品乱码久久久久久| 亚洲欧洲美洲综合色网| 国产黄色91视频| 日本一区二区三区国色天香 | 亚洲成人动漫一区| 一本色道久久综合亚洲aⅴ蜜桃| 国产精品视频看| 色狠狠综合天天综合综合| 国产精品免费视频一区| 日韩欧美的一区| 日韩av午夜在线观看| 欧美巨大另类极品videosbest | 99久久99久久免费精品蜜臀| 久久理论电影网| 精品午夜一区二区三区在线观看| 欧美一级理论片| 免费成人在线网站| 日韩亚洲欧美成人一区| 蜜臀va亚洲va欧美va天堂| 91精品国产综合久久精品| 香蕉影视欧美成人| 欧美另类高清zo欧美| 日本欧美久久久久免费播放网| 在线播放91灌醉迷j高跟美女 | 久久精品久久综合| 亚洲精品一区二区三区四区高清| 日韩成人免费看| 精品国产亚洲在线| 国产乱一区二区| 国产精品国产三级国产aⅴ原创| 99精品视频一区| 亚洲国产日韩综合久久精品| 欧美精三区欧美精三区| 美国三级日本三级久久99| 久久久精品日韩欧美| 成人高清免费观看| 亚洲一区二区三区三| 欧美午夜电影网| 久久66热偷产精品| 国产精品视频你懂的| 91福利精品第一导航| 青青草国产成人av片免费| 久久这里都是精品| av成人免费在线观看| 亚洲mv在线观看| 精品久久久久香蕉网| 成人av中文字幕| 日韩精品一二三四| 国产午夜精品久久久久久免费视| 色综合久久久久久久久| 亚洲风情在线资源站| 一区二区三区色| 国产91精品在线观看|