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

📄 columninfocachestorage.java

📁 羽量级数据持久层开发框架
💻 JAVA
字号:
package org.speedframework.cache;

//~--- non-JDK imports --------------------------------------------------------

import org.apache.log4j.Logger;

import org.speedframework.entity.CacheTableBean;
import org.speedframework.utilities.ConfigureParam;

//~--- JDK imports ------------------------------------------------------------

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 *  ��������Ϣ�����������Ҫְ����ô���
 *
 *
 * @version    $LastChangedRevision: 1945 $, 2007.09.29 at 02:14:29 CST
 * @author     <a href="mailto:falcon8848@gmail.com">piginzoo </a>
 */
public class ColumnInfoCacheStorage
 {

    /** ����������Ϣ */
    private static final Logger log = Logger.getLogger(ColumnInfoCacheStorage.class);   

    /**
     * ����������Ϣ��
     * ���������ʲô�ģ�
     * ��ε��ã���ø����ô���ʾ��
     *
     * @param key
     * @param value
     *
     * @throws Exception
     */
    public static synchronized void save(Object key, Object value) throws Exception {
        Map            map   = (Map) CacheStorage.get(ConfigureParam.TABLE_CACHE_NAME);
        CacheTableBean table = new CacheTableBean();

        table.setTablename((String) key);
        table.setColumnList((List) value);

        if (map == null) {
            map = new LinkedHashMap();
        }

        map.put(key, table);

        if (log.isDebugEnabled()) {
            log.debug("the table name is " + key + ",put column info in cache");
        }

        CacheStorage.put(ConfigureParam.TABLE_CACHE_NAME, map);
    }

    /**
     * ����������Ϣ��
     * ���������ʲô�ģ�
     * ��ε��ã���ø����ô���ʾ��
     *
     * @param key
     *
     * @throws Exception
     */
    public static synchronized void remove(Object key) throws Exception {
        Map map = (Map) CacheStorage.get(ConfigureParam.TABLE_CACHE_NAME);

        if ((map != null) && map.containsKey(key)) {
            map.remove(key);

            if (log.isDebugEnabled()) {
                log.debug("the table name is " + key + ",remove column info from cache");
            }

            CacheStorage.put(ConfigureParam.TABLE_CACHE_NAME, map);
        }
    }

    /**
     * ����������Ϣ��
     * ���������ʲô�ģ�
     * ��ε��ã���ø����ô���ʾ��
     *
     * @param key
     *
     * @return
     *
     * @throws Exception
     */
    public static synchronized Object get(Object key) throws Exception {
        Map            tables = null;
        CacheTableBean table  = null;

        try {
            tables = (Map) CacheStorage.get(ConfigureParam.TABLE_CACHE_NAME);

            if (tables != null) {
                if (tables.containsKey(key)) {
                    table = (CacheTableBean) tables.get(key);
                }
            } else {
                return null;
            }
        } catch (Exception ex) {
            throw ex;
        }

        return table;
    }
}

⌨️ 快捷键说明

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