|
|
|
@ -26,7 +26,6 @@ import java.util.Map;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
import java.util.concurrent.ConcurrentMap;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
import javax.cache.Cache;
|
|
|
|
|
import javax.cache.CacheManager;
|
|
|
|
@ -69,10 +68,9 @@ import org.redisson.client.protocol.decoder.MapScanResult;
|
|
|
|
|
import org.redisson.client.protocol.decoder.ObjectListReplayDecoder;
|
|
|
|
|
import org.redisson.client.protocol.decoder.ScanObjectEntry;
|
|
|
|
|
import org.redisson.connection.decoder.MapGetAllDecoder;
|
|
|
|
|
import org.redisson.misc.Hash;
|
|
|
|
|
|
|
|
|
|
import org.redisson.jcache.JMutableEntry.Action;
|
|
|
|
|
import org.redisson.jcache.configuration.JCacheConfiguration;
|
|
|
|
|
import org.redisson.misc.Hash;
|
|
|
|
|
|
|
|
|
|
import io.netty.util.internal.ThreadLocalRandom;
|
|
|
|
|
|
|
|
|
@ -314,7 +312,7 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V> {
|
|
|
|
|
|
|
|
|
|
V load(K key) {
|
|
|
|
|
RLock lock = getLock(key);
|
|
|
|
|
lock.lock(30, TimeUnit.MINUTES);
|
|
|
|
|
lock.lock();
|
|
|
|
|
try {
|
|
|
|
|
V value = getValueLocked(key);
|
|
|
|
|
if (value == null) {
|
|
|
|
@ -703,7 +701,7 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V> {
|
|
|
|
|
try {
|
|
|
|
|
if (!containsKey(key) || replaceExistingValues) {
|
|
|
|
|
RLock lock = getLock(key);
|
|
|
|
|
lock.lock(30, TimeUnit.MINUTES);
|
|
|
|
|
lock.lock();
|
|
|
|
|
try {
|
|
|
|
|
if (!containsKey(key)|| replaceExistingValues) {
|
|
|
|
|
V value;
|
|
|
|
@ -743,7 +741,7 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V> {
|
|
|
|
|
private RLock getLockedLock(K key) {
|
|
|
|
|
String lockName = getLockName(key);
|
|
|
|
|
RLock lock = redisson.getLock(lockName);
|
|
|
|
|
lock.lock(30, TimeUnit.MINUTES);
|
|
|
|
|
lock.lock();
|
|
|
|
|
return lock;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -761,7 +759,7 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V> {
|
|
|
|
|
long startTime = currentNanoTime();
|
|
|
|
|
if (config.isWriteThrough()) {
|
|
|
|
|
RLock lock = getLock(key);
|
|
|
|
|
lock.lock(30, TimeUnit.MINUTES);
|
|
|
|
|
lock.lock();
|
|
|
|
|
try {
|
|
|
|
|
List<Object> result = getAndPutValueLocked(key, value);
|
|
|
|
|
if (result.isEmpty()) {
|
|
|
|
@ -971,7 +969,7 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V> {
|
|
|
|
|
long startTime = currentNanoTime();
|
|
|
|
|
if (config.isWriteThrough()) {
|
|
|
|
|
RLock lock = getLock(key);
|
|
|
|
|
lock.lock(30, TimeUnit.MINUTES);
|
|
|
|
|
lock.lock();
|
|
|
|
|
try {
|
|
|
|
|
List<Object> result = getAndPutValueLocked(key, value);
|
|
|
|
|
if (result.isEmpty()) {
|
|
|
|
@ -1069,7 +1067,7 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V> {
|
|
|
|
|
long startTime = currentNanoTime();
|
|
|
|
|
if (config.isWriteThrough()) {
|
|
|
|
|
RLock lock = getLock(key);
|
|
|
|
|
lock.lock(30, TimeUnit.MINUTES);
|
|
|
|
|
lock.lock();
|
|
|
|
|
|
|
|
|
|
List<Object> result = getAndPutValue(key, value);
|
|
|
|
|
if (result.isEmpty()) {
|
|
|
|
@ -1091,7 +1089,7 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V> {
|
|
|
|
|
if (result.size() == 4) {
|
|
|
|
|
val = (V) result.get(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
deletedKeys.put(key, val);
|
|
|
|
|
}
|
|
|
|
|
cacheManager.getStatBean(this).addPuts(1);
|
|
|
|
@ -1173,7 +1171,7 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V> {
|
|
|
|
|
long startTime = currentNanoTime();
|
|
|
|
|
if (config.isWriteThrough()) {
|
|
|
|
|
RLock lock = getLock(key);
|
|
|
|
|
lock.lock(30, TimeUnit.MINUTES);
|
|
|
|
|
lock.lock();
|
|
|
|
|
try {
|
|
|
|
|
boolean result = putIfAbsentValueLocked(key, value);
|
|
|
|
|
if (result) {
|
|
|
|
@ -1255,7 +1253,7 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V> {
|
|
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
|
|
if (config.isWriteThrough()) {
|
|
|
|
|
RLock lock = getLock(key);
|
|
|
|
|
lock.lock(30, TimeUnit.MINUTES);
|
|
|
|
|
lock.lock();
|
|
|
|
|
try {
|
|
|
|
|
V oldValue = getValue(key);
|
|
|
|
|
boolean result = removeValue(key);
|
|
|
|
@ -1396,7 +1394,7 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V> {
|
|
|
|
|
boolean result;
|
|
|
|
|
if (config.isWriteThrough()) {
|
|
|
|
|
RLock lock = getLock(key);
|
|
|
|
|
lock.lock(30, TimeUnit.MINUTES);
|
|
|
|
|
lock.lock();
|
|
|
|
|
try {
|
|
|
|
|
result = removeValueLocked(key, value);
|
|
|
|
|
if (result) {
|
|
|
|
@ -1488,7 +1486,7 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V> {
|
|
|
|
|
long startTime = currentNanoTime();
|
|
|
|
|
if (config.isWriteThrough()) {
|
|
|
|
|
RLock lock = getLock(key);
|
|
|
|
|
lock.lock(30, TimeUnit.MINUTES);
|
|
|
|
|
lock.lock();
|
|
|
|
|
try {
|
|
|
|
|
Object value = getAndRemoveValue(key);
|
|
|
|
|
if (value != null) {
|
|
|
|
@ -1691,7 +1689,7 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V> {
|
|
|
|
|
long startTime = currentNanoTime();
|
|
|
|
|
if (config.isWriteThrough()) {
|
|
|
|
|
RLock lock = getLock(key);
|
|
|
|
|
lock.lock(30, TimeUnit.MINUTES);
|
|
|
|
|
lock.lock();
|
|
|
|
|
try {
|
|
|
|
|
long result = replaceValueLocked(key, oldValue, newValue);
|
|
|
|
|
if (result == 1) {
|
|
|
|
@ -1935,7 +1933,7 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V> {
|
|
|
|
|
long startTime = currentNanoTime();
|
|
|
|
|
if (config.isWriteThrough()) {
|
|
|
|
|
RLock lock = getLock(key);
|
|
|
|
|
lock.lock(30, TimeUnit.MINUTES);
|
|
|
|
|
lock.lock();
|
|
|
|
|
try {
|
|
|
|
|
boolean result = replaceValueLocked(key, value);
|
|
|
|
|
if (result) {
|
|
|
|
@ -1989,7 +1987,7 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V> {
|
|
|
|
|
long startTime = currentNanoTime();
|
|
|
|
|
if (config.isWriteThrough()) {
|
|
|
|
|
RLock lock = getLock(key);
|
|
|
|
|
lock.lock(30, TimeUnit.MINUTES);
|
|
|
|
|
lock.lock();
|
|
|
|
|
try {
|
|
|
|
|
V result = getAndReplaceValueLocked(key, value);
|
|
|
|
|
if (result != null) {
|
|
|
|
@ -2047,7 +2045,7 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V> {
|
|
|
|
|
if (config.isWriteThrough()) {
|
|
|
|
|
for (K key : keys) {
|
|
|
|
|
RLock lock = getLock(key);
|
|
|
|
|
lock.lock(30, TimeUnit.MINUTES);
|
|
|
|
|
lock.lock();
|
|
|
|
|
V result = getAndRemoveValue(key);
|
|
|
|
|
if (result != null) {
|
|
|
|
|
deletedKeys.put(key, result);
|
|
|
|
|