⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbcachemanager.java

📁 一套完整的工商12315的源程序jsp部分在12315里,后台JAVA部分在gs12315src里,没有打包数据库.
💻 JAVA
字号:
package com.gs.db.dbimp;

import com.gs.util.*;

/**
 * Central cache management of all caches used by InterOffice
 */
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 USER_PERMS_CACHE = 4;
    public static int UNIT_CACHE = 5;
    public static int NOTIFICATION_CACHE = 6;

    protected Cache[] caches;

    private boolean cacheEnabled = true;

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

        caches = new Cache[7];

        //Initialize all cache structures
        caches[USER_CACHE] = new Cache(512*1024, 6*HOUR);
        caches[USER_ID_CACHE] = new Cache(256*1024, 6*HOUR);
        caches[GROUP_CACHE] = new Cache(512*1024, 6*HOUR);
        caches[GROUP_ID_CACHE] = new Cache(128*1024, 6*HOUR);        
        caches[USER_PERMS_CACHE] = new Cache(768*1024, 24*HOUR);
        caches[UNIT_CACHE] = new Cache(256*1024, 6*HOUR);
        caches[NOTIFICATION_CACHE] = new Cache(256*1024, 1*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 jive servers.
    }
	
    public void removeUserPerm(Object userID) {
    	caches[USER_PERMS_CACHE].remove(userID);
	}
    

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

    public boolean isCacheEnabled() {
        return cacheEnabled;
    }

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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -