All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yixan.tools.common.cache.ICacheKeys Maven / Gradle / Ivy

There is a newer version: 3.7.1
Show newest version
package com.yixan.tools.common.cache;

/**
 * 强类型缓存KEY
 *
 * 
public interface CacheKeys {
    enum SKV implements ICacheKeys.KeyValue<String> {
        CLIENT_CODE,
        BUSINESS_CODE;
        public Class<String> type() { return String.class; }
    }
    enum IKV implements ISessionKey.KeyValue<Integer> {
        DATA_VALUE;
        public Class<Integer> type() { return Integer.class; }
    }
    enum ResourceList implements ICacheKeys.KeyList<ResourceBean> {
        PERMISSION;
        public Class<ResourceBean> type() { return ResourceBean.class; }
    }
}
cacheService.set(CacheKeys.SKV.CLIENT_CODE, 0); // 编译报错
cacheService.set(CacheKeys.IKV.DATA_VALUE, "000"); // 编译报错
String businessCode = cacheService.get(CacheKeys.SKV.BUSINESS_CODE); // 类型自动转换
List<ResourceBean> resources = cacheService.get(CacheKeys.ResourceList.PERMISSION); // 类型自动转换
 * 
* * @author zhaohuihua * @version C01 2017年5月27日 * @since v1.0 */ public interface ICacheKeys { String name(); Class type(); /** 只允许缓存指定类型的值的KEY **/ interface KeyValue extends ICacheKeys { } /** 只允许缓存指定类型的数组的KEY **/ interface KeyList extends ICacheKeys { } /** 只允许缓存指定类型的值的动态KEY **/ interface FieldValue extends ICacheKeys { } /** 只允许缓存指定类型的数组的动态KEY **/ interface FieldList extends ICacheKeys { } /** 具有明确过期时间的KEY **/ interface ExpireFixed { /** 过期时间 **/ long time(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy