程序包 com.sh.util
类 CacheRedis
java.lang.Object
com.sh.util.CacheRedis
- 所有已实现的接口:
AutoCloseable
- 直接已知子类:
DSCacheRedis
Description: 基于redis的cache
Title:首亨软件 - TSS/CRM等
- 从以下版本开始:
- 2016年11月23日
-
字段概要
字段修饰符和类型字段说明static booleanstatic intprotected static org.apache.logging.log4j.Logger -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static voidclearAll()voidclose()longgetHashSize(String key) getHashValue(String key, String field) getHashValues(String key, String[] fields) 从hash中获取多字段值longgetIncrement(String key) longgetIncrement(String key, long timeoutSeconds) longlonggetIncrementSeqByDay(String type) 按天生成自增长序列intintlonglongstatic org.springframework.data.redis.core.RedisTemplatestatic Stringstatic org.springframework.data.redis.core.StringRedisTemplatestatic StringgetStringSecurity(String key) 获取值,获取完后立即关闭连接static booleaninit()booleanboolean是否存在booleanisHashExists(String key, String field) 判断hash表对应的值是否存在static booleanisRedis()static StringprintListinerLog(org.apache.logging.log4j.Logger log4j) 监控日志 在DataSourceListener中使用voidputHashValue(String key, String field, Object value) voidputHashValues(String key, Map<String, Object> data) voidvoidvoidvoidvoidvoidstatic booleanputStringSecurity(String key, String value) static booleanputStringSecurity(String key, String value, int seconds) 设置值到redis,设置完后直接关闭连接voidvoidvoidvoidremoveHash(String key, String field) voidremoveHashs(String key, String... fields) static booleanremoveSecurity(String key) voidsetInitClassInfo(String initClassInfo) 设置初始化实例类 主要用于日志输出long获取key的过期时间。
-
字段详细资料
-
log4j
protected static org.apache.logging.log4j.Logger log4j -
CHECK_REDIS_CONNECT_TIMEOUT
public static boolean CHECK_REDIS_CONNECT_TIMEOUT -
CHECK_TIMEOUT_SECONDS
public static int CHECK_TIMEOUT_SECONDS
-
-
构造器详细资料
-
CacheRedis
public CacheRedis() -
CacheRedis
-
-
方法详细资料
-
setInitClassInfo
设置初始化实例类 主要用于日志输出- 参数:
initClassInfo- 实例化类信息描述
-
init
public static boolean init() -
isRedis
public static boolean isRedis() -
printListinerLog
监控日志 在DataSourceListener中使用- 参数:
log4j- Logger- 返回:
- String
-
isConnected
public boolean isConnected() -
close
public void close()- 指定者:
close在接口中AutoCloseable
-
getStringRedisTemplate
public static org.springframework.data.redis.core.StringRedisTemplate getStringRedisTemplate() -
getRedisTemplate
public static org.springframework.data.redis.core.RedisTemplate getRedisTemplate() -
ttl
获取key的过期时间。如果key存在过期时间,返回剩余生存时间(秒);如果key是永久的,返回-1;如果key不存在或者已过期,返回-2- 参数:
key-- 返回:
- long
-
putString
-
putString
-
getString
-
putValue
-
putValue
-
putInt
-
putInt
-
putLong
-
putLong
-
getInt
-
getInt
-
getLong
-
getLong
-
getValue
-
putHashValue
-
putHashValues
-
getHashValue
-
getHashValues
从hash中获取多字段值- 参数:
key-fields-- 返回:
- 返回每个字段对应的值
-
getHashSize
-
removeHash
-
removeHashs
-
remove
-
getIncrement
-
getIncrement
-
getIncrementSeqByDay
public long getIncrementSeqByDay() -
getIncrementSeqByDay
按天生成自增长序列- 返回:
-
isExists
是否存在- 参数:
key- String- 返回:
- boolean
-
isHashExists
判断hash表对应的值是否存在- 参数:
key- Stringfield- String- 返回:
- boolean
-
clearAll
public static void clearAll() -
putStringSecurity
-
putStringSecurity
设置值到redis,设置完后直接关闭连接- 参数:
key- Stringvalue- Stringseconds- int- 返回:
- boolean
-
getStringSecurity
获取值,获取完后立即关闭连接- 参数:
key- String- 返回:
- String
-
getStringAndRemoveSecurity
-
removeSecurity
-