类 RedisGenericCache

java.lang.Object
net.oschina.j2cache.redis.RedisGenericCache
所有已实现的接口:
Cache, Level2Cache

public class RedisGenericCache extends Object implements Level2Cache
Redis 缓存操作封装,基于 region+_key 实现多个 Region 的缓存(
作者:
Winter Lau(javayou@gmail.com)
  • 构造器详细资料

    • RedisGenericCache

      public RedisGenericCache(String namespace, String region, RedisClient client, int scanCount)
      缓存构造
      参数:
      namespace - 命名空间,用于在多个实例中避免 _key 的重叠
      region - 缓存区域的名称
      client - 缓存客户端接口
  • 方法详细资料

    • supportTTL

      public boolean supportTTL()
      从接口复制的说明: Level2Cache
      是否支持缓存 TTL 的设置
      指定者:
      supportTTL 在接口中 Level2Cache
      返回:
      true/false if cache support ttl setting
    • getBytes

      public byte[] getBytes(String key)
      从接口复制的说明: Level2Cache
      读取缓存数据字节数组
      指定者:
      getBytes 在接口中 Level2Cache
      参数:
      key - cache key
      返回:
      cache data
    • getBytes

      public List<byte[]> getBytes(Collection<String> keys)
      从接口复制的说明: Level2Cache
      同时读取多个 Key
      指定者:
      getBytes 在接口中 Level2Cache
      参数:
      keys - multiple cache key
      返回:
      cache values
    • setBytes

      public void setBytes(String key, byte[] bytes)
      从接口复制的说明: Level2Cache
      设置缓存数据字节数组
      指定者:
      setBytes 在接口中 Level2Cache
      参数:
      key - cache key
      bytes - cache data
    • setBytes

      public void setBytes(Map<String,byte[]> bytes)
      从接口复制的说明: Level2Cache
      同时设置多个数据
      指定者:
      setBytes 在接口中 Level2Cache
      参数:
      bytes - cache data
    • setBytes

      public void setBytes(String key, byte[] bytes, long timeToLiveInSeconds)
      从接口复制的说明: Level2Cache
      设置缓存数据字节数组(带有效期)
      指定者:
      setBytes 在接口中 Level2Cache
      参数:
      key - cache key
      bytes - cache data
      timeToLiveInSeconds - cache ttl
    • setBytes

      public void setBytes(Map<String,byte[]> bytes, long timeToLiveInSeconds)
      从接口复制的说明: Level2Cache
      批量设置带 TTL 的缓存数据
      指定者:
      setBytes 在接口中 Level2Cache
      参数:
      bytes - cache data
      timeToLiveInSeconds - cache ttl
    • exists

      public boolean exists(String key)
      从接口复制的说明: Level2Cache
      判断缓存数据是否存在
      指定者:
      exists 在接口中 Cache
      指定者:
      exists 在接口中 Level2Cache
      参数:
      key - cache key
      返回:
      true if cache key exists in redis
    • keys

      public Collection<String> keys()
      1、线上redis服务大概率会禁用或重命名keys命令; 2、keys命令效率太低容易致使redis宕机; 所以使用scan命令替换keys命令操作,增加可用性及提升执行性能
      指定者:
      keys 在接口中 Cache
      指定者:
      keys 在接口中 Level2Cache
      返回:
      返回键的集合
    • evict

      public void evict(String... keys)
      从接口复制的说明: Level2Cache
      Remove items from the cache
      指定者:
      evict 在接口中 Cache
      指定者:
      evict 在接口中 Level2Cache
      参数:
      keys - Cache key
    • clear

      public void clear()
      已使用scan命令替换keys命令操作
      指定者:
      clear 在接口中 Cache
      指定者:
      clear 在接口中 Level2Cache