程序包 com.sh.util

类 CacheRedis

java.lang.Object
com.sh.util.CacheRedis
所有已实现的接口:
AutoCloseable
直接已知子类:
DSCacheRedis

public class CacheRedis extends Object implements AutoCloseable

Description: 基于redis的cache

Title:首亨软件 - TSS/CRM等

从以下版本开始:
2016年11月23日
  • 字段详细资料

    • 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

      public CacheRedis(String initClassInfo)
  • 方法详细资料

    • setInitClassInfo

      public void setInitClassInfo(String initClassInfo)
      设置初始化实例类 主要用于日志输出
      参数:
      initClassInfo - 实例化类信息描述
    • init

      public static boolean init()
    • isRedis

      public static boolean isRedis()
    • printListinerLog

      public static String printListinerLog(org.apache.logging.log4j.Logger log4j)
      监控日志 在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

      public long ttl(String key)
      获取key的过期时间。如果key存在过期时间,返回剩余生存时间(秒);如果key是永久的,返回-1;如果key不存在或者已过期,返回-2
      参数:
      key -
      返回:
      long
    • putString

      public void putString(String key, String value)
    • putString

      public void putString(String key, String value, int seconds)
    • getString

      public String getString(String key)
    • putValue

      public void putValue(String key, Object value)
    • putValue

      public void putValue(String key, Object value, int seconds)
    • putInt

      public void putInt(String key, int value)
    • putInt

      public void putInt(String key, int value, int seconds)
    • putLong

      public void putLong(String key, long value)
    • putLong

      public void putLong(String key, long value, int seconds)
    • getInt

      public int getInt(String key)
    • getInt

      public int getInt(String key, int defaultValue)
    • getLong

      public long getLong(String key)
    • getLong

      public long getLong(String key, long defaultValue)
    • getValue

      public Object getValue(String key)
    • putHashValue

      public void putHashValue(String key, String field, Object value)
    • putHashValues

      public void putHashValues(String key, Map<String,Object> data)
    • getHashValue

      public Object getHashValue(String key, String field)
    • getHashValues

      public Map<String,Object> getHashValues(String key, String[] fields)
      从hash中获取多字段值
      参数:
      key -
      fields -
      返回:
      返回每个字段对应的值
    • getHashSize

      public long getHashSize(String key)
    • removeHash

      public void removeHash(String key, String field)
    • removeHashs

      public void removeHashs(String key, String... fields)
    • remove

      public void remove(String key)
    • getIncrement

      public long getIncrement(String key)
    • getIncrement

      public long getIncrement(String key, long timeoutSeconds)
    • getIncrementSeqByDay

      public long getIncrementSeqByDay()
    • getIncrementSeqByDay

      public long getIncrementSeqByDay(String type)
      按天生成自增长序列
      返回:
    • isExists

      public boolean isExists(String key)
      是否存在
      参数:
      key - String
      返回:
      boolean
    • isHashExists

      public boolean isHashExists(String key, String field)
      判断hash表对应的值是否存在
      参数:
      key - String
      field - String
      返回:
      boolean
    • clearAll

      public static void clearAll()
    • putStringSecurity

      public static boolean putStringSecurity(String key, String value)
    • putStringSecurity

      public static boolean putStringSecurity(String key, String value, int seconds)
      设置值到redis,设置完后直接关闭连接
      参数:
      key - String
      value - String
      seconds - int
      返回:
      boolean
    • getStringSecurity

      public static String getStringSecurity(String key)
      获取值,获取完后立即关闭连接
      参数:
      key - String
      返回:
      String
    • getStringAndRemoveSecurity

      public static String getStringAndRemoveSecurity(String key)
    • removeSecurity

      public static boolean removeSecurity(String key)