update 更新 RedisUtils 增加 注册监听器方法

master
疯狂的狮子li 4 years ago
parent 1445d6d24a
commit bcbc7c1d47

@ -94,8 +94,8 @@ public class RedisUtils {
/**
* TTL
*
* @param key
* @param value
* @param key
* @param value
* @param isSaveTtl TTL(: setttl90 set90)
* @since Redis 6.X 使 setAndKeepTTL 5.X
*/
@ -128,6 +128,19 @@ public class RedisUtils {
result.expire(timeout, timeUnit);
}
/**
*
*
* key `notify-keyspace-events` redis
*
* @param key
* @param listener
*/
public static <T> void addObjectListener(final String key, final ObjectListener listener) {
RBucket<T> result = CLIENT.getBucket(key);
result.addListener(listener);
}
/**
*
*
@ -177,19 +190,16 @@ public class RedisUtils {
/**
*
*
* @param key
* @param key
*/
public static boolean deleteObject(final String key) {
return CLIENT.getBucket(key).delete();
}
/* */
/**
*
*
* @param collection
* @return
*/
public static void deleteObject(final Collection collection) {
RBatch batch = CLIENT.createBatch();
@ -211,6 +221,19 @@ public class RedisUtils {
return rList.addAll(dataList);
}
/**
* List
*
* key `notify-keyspace-events` redis
*
* @param key
* @param listener
*/
public static <T> void addListListener(final String key, final ObjectListener listener) {
RList<T> rList = CLIENT.getList(key);
rList.addListener(listener);
}
/**
* list
*
@ -234,11 +257,24 @@ public class RedisUtils {
return rSet.addAll(dataSet);
}
/**
* Set
*
* key `notify-keyspace-events` redis
*
* @param key
* @param listener
*/
public static <T> void addSetListener(final String key, final ObjectListener listener) {
RSet<T> rSet = CLIENT.getSet(key);
rSet.addListener(listener);
}
/**
* set
*
* @param key
* @return
* @param key key
* @return set
*/
public static <T> Set<T> getCacheSet(final String key) {
RSet<T> rSet = CLIENT.getSet(key);
@ -248,8 +284,8 @@ public class RedisUtils {
/**
* Map
*
* @param key
* @param dataMap
* @param key
* @param dataMap
*/
public static <T> void setCacheMap(final String key, final Map<String, T> dataMap) {
if (dataMap != null) {
@ -258,11 +294,24 @@ public class RedisUtils {
}
}
/**
* Map
*
* key `notify-keyspace-events` redis
*
* @param key
* @param listener
*/
public static <T> void addMapListener(final String key, final ObjectListener listener) {
RMap<String, T> rMap = CLIENT.getMap(key);
rMap.addListener(listener);
}
/**
* Map
*
* @param key
* @return
* @param key
* @return map
*/
public static <T> Map<String, T> getCacheMap(final String key) {
RMap<String, T> rMap = CLIENT.getMap(key);

Loading…
Cancel
Save