add 增加 RedisUtils 操作原子值方法

feature/model
疯狂的狮子li 3 years ago
parent 4941aaa5c1
commit b01d45cf5c

@ -364,6 +364,50 @@ public class RedisUtils {
return rMap.getAll(hKeys); return rMap.getAll(hKeys);
} }
/**
*
*
* @param key Redis
* @param value
*/
public static void setAtomicValue(String key, long value) {
RAtomicLong atomic = CLIENT.getAtomicLong(key);
atomic.set(value);
}
/**
*
*
* @param key Redis
* @return
*/
public static long getAtomicValue(String key) {
RAtomicLong atomic = CLIENT.getAtomicLong(key);
return atomic.get();
}
/**
*
*
* @param key Redis
* @return
*/
public static long incrAtomicValue(String key) {
RAtomicLong atomic = CLIENT.getAtomicLong(key);
return atomic.incrementAndGet();
}
/**
*
*
* @param key Redis
* @return
*/
public static long decrAtomicValue(String key) {
RAtomicLong atomic = CLIENT.getAtomicLong(key);
return atomic.decrementAndGet();
}
/** /**
* *
* *

Loading…
Cancel
Save