派生自 projectDept/qhighschool

胡仁荣
2023-07-18 885290e4d0d0c7fad3f538d901c616e49c3d6985
src/main/java/com/qxueyou/scc/base/service/ICacheService.java
@@ -1,34 +1,36 @@
package com.qxueyou.scc.base.service;
import org.springframework.data.redis.core.RedisTemplate;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
 * 缓存服务接口
 * 缓存服务接口
 * 
 * @author 德虎
 * @author 德虎
 *
 */
public interface ICacheService {
   /**
    * 根据key值获取指定类型对象
    * 根据key值获取指定类型对象
    * 
    * @param key
    *            对象key值
    *            对象key值
    * @param cls
    *            对象类型
    *            对象类型
    * @return
    */
   <T> T get(String key, Class<T> cls);
   /**
    * 根据key值获取指定类型对象
    * 根据key值获取指定类型对象
    * 
    * @param key
    *            对象key值
    *            对象key值
    * @return
    */
   <T> T get(String key);
@@ -40,7 +42,7 @@
   Long decr(String key);
   /**
    * 根据key值获取指定类型对象
    * 根据key值获取指定类型对象
    * 
    * @param keys
    * @return
@@ -48,90 +50,90 @@
   Map<String, Object> getBulk(String... keys);
   /**
    * 将对象缓存到缓存池
    * 将对象缓存到缓存池
    * 
    * @param key
    *            对象key值
    *            对象key值
    * @param expiredTime
    *            超时时间,单位秒
    *            超时时间,单位秒
    * @param obj
    *            要缓存的对象
    *            要缓存的对象
    * @return
    */
   void set(String key, int expiredTime, Object obj);
   /**
    * 将对象缓存到缓存池,永不过期
    * 将对象缓存到缓存池,永不过期
    * 
    * @param key
    *            对象key值
    *            对象key值
    * @param obj
    *            要缓存的对象
    *            要缓存的对象
    * @return
    */
   void set(String key, Object obj);
   /**
    * 将对象缓存到缓存池
    * 将对象缓存到缓存池
    * 
    * @param key
    *            cache名称
    *            cache名称
    * @param hashKey
    *            键值
    *            键值
    * @param obj
    *            要缓存的对象
    *            要缓存的对象
    * @return
    */
   void set(String key, String hashKey, Object obj);
   /**
    * 将对象缓存到缓存池
    * 将对象缓存到缓存池
    * 
    * @param key
    *            对象key值
    *            对象key值
    * @param expiredTime
    *            超时时间,单位秒
    *            超时时间,单位秒
    * @param obj
    *            要缓存的对象
    *            要缓存的对象
    * @return
    */
   boolean add(String key, int expiredTime, Object obj);
   /**
    * 将对象从缓存池删除
    * 将对象从缓存池删除
    * 
    * @param key
    *            对象key值
    *            对象key值
    * @return
    */
   void delete(String key);
   /**
    * 追加缓存池的值
    * 追加缓存池的值
    * 
    * @param key
    *            对象key值
    *            对象key值
    * @return
    */
   void append(String key, String value);
   /**
    * 获取list缓存中key所有value值
    * 获取list缓存中key所有value值
    */
   <T> List<T> lstAll(String key);
   /**
    * 向list缓存中放入值
    * 向list缓存中放入值
    */
   void lstRightPush(String key, Object value);
   /**
    * 向list缓存中放入值
    * 向list缓存中放入值
    */
   <T> void lstRightPushAll(String key, Collection<T> values);
   /**
    * 从列表获取指定范围内的数据
    * 从列表获取指定范围内的数据
    * 
    * @param key
    * @param start
@@ -145,17 +147,17 @@
   void lstClear(String key);
   /**
    * 根据key,index删除list中的value
    * 根据key,index删除list中的value
    */
   void lstRemove(String key, Object value);
   /**
    * 通过key返回list中的值,并移除值
    * 通过key返回list中的值,并移除值
    */
   String lstLeftPop(String key);
   
   /**
     * 向hash缓存中存入对象
     * 向hash缓存中存入对象
     *
     * @param key
     * @param hashKey
@@ -164,7 +166,7 @@
    void putKeyForHash(Object key, Object hashKey, Object value);
    
    /**
     * 对key设置过其实键
     * 对key设置过其实键
     * @param key
     * @param timeout
     * @param unit
@@ -172,12 +174,13 @@
   void expire(String key, long timeout, TimeUnit unit);
   
   /**
    * 如果不存在就添加
    * 如果不存在就添加
    * @param key
    * @param obj
    * @return
    */
   boolean setIfAbsent(String key, Object obj);
   <K,V> RedisTemplate<K,V> template();
}