缓存接口使用说明

使用步骤

直接依赖即可

@Autowired
private Icache cache;

方法说明

1、获取缓存中存储的对象

方法名:get

参数:

  1. key:缓存的key
#### 返回值:
  1. T:缓存中的对象

2、向缓存中存储对象(永久有效)

方法名:put

参数:

  1. key:缓存中对象的key
  2. value:要缓存的对象

3、向缓存中存储对象(指定有效期)

方法名:put

参数:

  1. key:缓存的key
  2. value:要缓存的对象
  3. exp:数据有效期,以秒为单位

4、删除缓存中的对象

方法名:remove

参数:

  1. key:缓存中对象的key

5、清空缓存中的对象

方法名:clear

参数:无

示例

public void putCache(String cacheKey, List<CartVo> itemList) {
    //压入缓存
    cache.put(cacheKey, itemList);
}
public void clean() {
    String cacheKey = this.cartReadManager.getSessionKey();
    //删除缓存中指定对象
    this.cache.remove(cacheKey);
}

results matching ""

    No results matching ""