Interface StringRedisCache

All Superinterfaces:
org.springframework.beans.factory.InitializingBean
All Known Implementing Classes:
AbstractStringRedisCache

public interface StringRedisCache extends org.springframework.beans.factory.InitializingBean

Description: 简单数据的Redis存储

很多使用Redis进行缓存的数据都比较简单,通常就是单一的键值对存储。例如,手机验证码、JustAuth的State数据、第三方集成的Token等。 因此,抽象出SimpleRedisCache,对此类操作进行定义。

Author:
: gengwei.zheng
Date:
: 2021/5/21 23:37
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    cache(String key, String value)
    存入缓存
    void
    cache(String key, String value, long timeout)
    存入缓存
    boolean
    是否存在key,如果对应key的value值已过期,也返回false
    boolean
     
    get(String key)
    获取缓存内容

    Methods inherited from interface org.springframework.beans.factory.InitializingBean

    afterPropertiesSet
  • Method Details

    • cache

      void cache(String key, String value)
      存入缓存
      Parameters:
      key - 缓存key
      value - 缓存内容
    • cache

      void cache(String key, String value, long timeout)
      存入缓存
      Parameters:
      key - 缓存key
      value - 缓存内容
      timeout - 指定缓存过期时间(毫秒)
    • get

      String get(String key)
      获取缓存内容
      Parameters:
      key - 缓存key
      Returns:
      缓存内容
    • containsKey

      boolean containsKey(String key)
      是否存在key,如果对应key的value值已过期,也返回false
      Parameters:
      key - 缓存key
      Returns:
      true:存在key,并且value没过期;false:key不存在或者已过期
    • delete

      boolean delete(String key)