|
|
|
@ -392,24 +392,27 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
|
|
|
|
|
if (containsKey(key)) {
|
|
|
|
|
Long updateTimeout = getUpdateTimeout();
|
|
|
|
|
List<Object> res = evalWrite(getRawName(), codec, RedisCommands.EVAL_LIST,
|
|
|
|
|
"local value = redis.call('hget', KEYS[1], ARGV[4]);"
|
|
|
|
|
+"if ARGV[2] == '0' then "
|
|
|
|
|
"if ARGV[2] == '0' then "
|
|
|
|
|
+ "redis.call('hdel', KEYS[1], ARGV[4]); "
|
|
|
|
|
+ "redis.call('zrem', KEYS[2], ARGV[4]); "
|
|
|
|
|
+ "local value = redis.call('hget', KEYS[1], ARGV[4]);"
|
|
|
|
|
+ "local msg = struct.pack('Lc0Lc0', string.len(ARGV[4]), ARGV[4], string.len(tostring(value)), tostring(value)); "
|
|
|
|
|
+ "redis.call('publish', KEYS[4], msg); "
|
|
|
|
|
+ "local syncMsg = struct.pack('Lc0Lc0d', string.len(ARGV[4]), ARGV[4], string.len(tostring(value)), tostring(value), ARGV[6]); "
|
|
|
|
|
+ "local syncs = redis.call('publish', KEYS[7], syncMsg); "
|
|
|
|
|
+ "return {0, syncs};"
|
|
|
|
|
+ "elseif ARGV[2] ~= '-1' then "
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[4], ARGV[5]); "
|
|
|
|
|
+ "redis.call('zadd', KEYS[2], ARGV[2], ARGV[4]); "
|
|
|
|
|
+ "local oldValueRequired = tonumber(redis.call('get', KEYS[9])); "
|
|
|
|
|
+ "local msg, syncMsg; "
|
|
|
|
|
+ "if oldValueRequired == nil or oldValueRequired < 1 then "
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[4], ARGV[5]); "
|
|
|
|
|
+ "redis.call('zadd', KEYS[2], ARGV[2], ARGV[4]); "
|
|
|
|
|
+ "msg = struct.pack('Lc0Lc0h', string.len(ARGV[4]), ARGV[4], string.len(ARGV[5]), ARGV[5], -1); "
|
|
|
|
|
+ "syncMsg = struct.pack('Lc0Lc0hd', string.len(ARGV[4]), ARGV[4], string.len(ARGV[5]), ARGV[5], -1, ARGV[6]); "
|
|
|
|
|
+ "else "
|
|
|
|
|
+ "local value = redis.call('hget', KEYS[1], ARGV[4]);"
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[4], ARGV[5]); "
|
|
|
|
|
+ "redis.call('zadd', KEYS[2], ARGV[2], ARGV[4]); "
|
|
|
|
|
+ "msg = struct.pack('Lc0Lc0Lc0', string.len(ARGV[4]), ARGV[4], string.len(ARGV[5]), ARGV[5], string.len(tostring(value)), tostring(value)); "
|
|
|
|
|
+ "syncMsg = struct.pack('Lc0Lc0Lc0d', string.len(ARGV[4]), ARGV[4], string.len(ARGV[5]), ARGV[5], string.len(tostring(value)), tostring(value), ARGV[6]); "
|
|
|
|
|
+ "end; "
|
|
|
|
@ -417,13 +420,15 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
|
|
|
|
|
+ "local syncs = redis.call('publish', KEYS[8], syncMsg); "
|
|
|
|
|
+ "return {1, syncs};"
|
|
|
|
|
+ "else "
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[4], ARGV[5]); "
|
|
|
|
|
+ "local oldValueRequired = tonumber(redis.call('get', KEYS[9])); "
|
|
|
|
|
+ "local msg, syncMsg; "
|
|
|
|
|
+ "if oldValueRequired == nil or oldValueRequired < 1 then "
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[4], ARGV[5]); "
|
|
|
|
|
+ "msg = struct.pack('Lc0Lc0h', string.len(ARGV[4]), ARGV[4], string.len(ARGV[5]), ARGV[5], -1); "
|
|
|
|
|
+ "syncMsg = struct.pack('Lc0Lc0hd', string.len(ARGV[4]), ARGV[4], string.len(ARGV[5]), ARGV[5], -1, ARGV[6]); "
|
|
|
|
|
+ "else "
|
|
|
|
|
+ "local value = redis.call('hget', KEYS[1], ARGV[4]);"
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[4], ARGV[5]); "
|
|
|
|
|
+ "msg = struct.pack('Lc0Lc0Lc0', string.len(ARGV[4]), ARGV[4], string.len(ARGV[5]), ARGV[5], string.len(tostring(value)), tostring(value)); "
|
|
|
|
|
+ "syncMsg = struct.pack('Lc0Lc0Lc0d', string.len(ARGV[4]), ARGV[4], string.len(ARGV[5]), ARGV[5], string.len(tostring(value)), tostring(value), ARGV[6]); "
|
|
|
|
|
+ "end; "
|
|
|
|
@ -500,23 +505,26 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
|
|
|
|
|
"exists = false;" +
|
|
|
|
|
"end;" +
|
|
|
|
|
"if exists then "
|
|
|
|
|
+ "local value = redis.call('hget', KEYS[1], ARGV[i]);"
|
|
|
|
|
+ "if ARGV[2] == '0' then "
|
|
|
|
|
+ "redis.call('hdel', KEYS[1], ARGV[i]); "
|
|
|
|
|
+ "redis.call('zrem', KEYS[2], ARGV[i]); "
|
|
|
|
|
+ "local value = redis.call('hget', KEYS[1], ARGV[i]);"
|
|
|
|
|
+ "local msg = struct.pack('Lc0Lc0', string.len(ARGV[i]), ARGV[i], string.len(tostring(value)), tostring(value)); "
|
|
|
|
|
+ "redis.call('publish', KEYS[4], msg); "
|
|
|
|
|
+ "local syncMsg = struct.pack('Lc0Lc0d', string.len(ARGV[i]), ARGV[i], string.len(tostring(value)), tostring(value), ARGV[4]); "
|
|
|
|
|
+ "syncs = syncs + redis.call('publish', KEYS[7], syncMsg); "
|
|
|
|
|
+ "elseif ARGV[2] ~= '-1' then "
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[i], ARGV[i+1]); "
|
|
|
|
|
+ "redis.call('zadd', KEYS[2], ARGV[2], ARGV[i]); "
|
|
|
|
|
+ "local oldValueRequired = tonumber(redis.call('get', KEYS[9])); "
|
|
|
|
|
+ "local msg, syncMsg; "
|
|
|
|
|
+ "if oldValueRequired == nil or oldValueRequired < 1 then "
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[i], ARGV[i+1]); "
|
|
|
|
|
+ "redis.call('zadd', KEYS[2], ARGV[2], ARGV[i]); "
|
|
|
|
|
+ "msg = struct.pack('Lc0Lc0h', string.len(ARGV[i]), ARGV[i], string.len(ARGV[i+1]), ARGV[i+1], -1); "
|
|
|
|
|
+ "syncMsg = struct.pack('Lc0Lc0hd', string.len(ARGV[i]), ARGV[i], string.len(ARGV[i+1]), ARGV[i+1], -1, ARGV[4]); "
|
|
|
|
|
+ "else "
|
|
|
|
|
+ "local value = redis.call('hget', KEYS[1], ARGV[i]);"
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[i], ARGV[i+1]); "
|
|
|
|
|
+ "redis.call('zadd', KEYS[2], ARGV[2], ARGV[i]); "
|
|
|
|
|
+ "msg = struct.pack('Lc0Lc0Lc0', string.len(ARGV[i]), ARGV[i], string.len(ARGV[i+1]), ARGV[i+1], string.len(tostring(value)), tostring(value)); "
|
|
|
|
|
+ "syncMsg = struct.pack('Lc0Lc0Lc0d', string.len(ARGV[i]), ARGV[i], string.len(ARGV[i+1]), ARGV[i+1], string.len(tostring(value)), tostring(value), ARGV[4]); "
|
|
|
|
|
+ "end; "
|
|
|
|
@ -524,13 +532,15 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
|
|
|
|
|
+ "syncs = syncs + redis.call('publish', KEYS[8], syncMsg); "
|
|
|
|
|
+ "added = added + 1;"
|
|
|
|
|
+ "else "
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[i], ARGV[i+1]); "
|
|
|
|
|
+ "local oldValueRequired = tonumber(redis.call('get', KEYS[9])); "
|
|
|
|
|
+ "local msg, syncMsg; "
|
|
|
|
|
+ "if oldValueRequired == nil or oldValueRequired < 1 then "
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[i], ARGV[i+1]); "
|
|
|
|
|
+ "msg = struct.pack('Lc0Lc0h', string.len(ARGV[i]), ARGV[i], string.len(ARGV[i+1]), ARGV[i+1], -1); "
|
|
|
|
|
+ "syncMsg = struct.pack('Lc0Lc0hd', string.len(ARGV[i]), ARGV[i], string.len(ARGV[i+1]), ARGV[i+1], -1, ARGV[4]); "
|
|
|
|
|
+ "else "
|
|
|
|
|
+ "local value = redis.call('hget', KEYS[1], ARGV[i]);"
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[i], ARGV[i+1]); "
|
|
|
|
|
+ "msg = struct.pack('Lc0Lc0Lc0', string.len(ARGV[i]), ARGV[i], string.len(ARGV[i+1]), ARGV[i+1], string.len(tostring(value)), tostring(value)); "
|
|
|
|
|
+ "syncMsg = struct.pack('Lc0Lc0Lc0d', string.len(ARGV[i]), ARGV[i], string.len(ARGV[i+1]), ARGV[i+1], string.len(tostring(value)), tostring(value), ARGV[4]); "
|
|
|
|
|
+ "end; "
|
|
|
|
@ -627,24 +637,27 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
|
|
|
|
|
"exists = false;" +
|
|
|
|
|
"end;" +
|
|
|
|
|
"if exists then "
|
|
|
|
|
+ "local value = redis.call('hget', KEYS[1], ARGV[4]);"
|
|
|
|
|
+ "if ARGV[2] == '0' then "
|
|
|
|
|
+ "redis.call('hdel', KEYS[1], ARGV[4]); "
|
|
|
|
|
+ "redis.call('zrem', KEYS[2], ARGV[4]); "
|
|
|
|
|
+ "local value = redis.call('hget', KEYS[1], ARGV[4]);"
|
|
|
|
|
+ "local msg = struct.pack('Lc0Lc0', string.len(ARGV[4]), ARGV[4], string.len(tostring(value)), tostring(value)); "
|
|
|
|
|
+ "redis.call('publish', KEYS[4], msg); "
|
|
|
|
|
+ "local syncMsg = struct.pack('Lc0Lc0d', string.len(ARGV[4]), ARGV[4], string.len(tostring(value)), tostring(value), ARGV[6]); "
|
|
|
|
|
+ "local syncs = redis.call('publish', KEYS[7], syncMsg); "
|
|
|
|
|
+ "return {0, syncs};"
|
|
|
|
|
+ "elseif ARGV[2] ~= '-1' then "
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[4], ARGV[5]); "
|
|
|
|
|
+ "redis.call('zadd', KEYS[2], ARGV[2], ARGV[4]); "
|
|
|
|
|
+ "local oldValueRequired = tonumber(redis.call('get', KEYS[9])); "
|
|
|
|
|
+ "local msg, syncMsg; "
|
|
|
|
|
+ "if oldValueRequired == nil or oldValueRequired < 1 then "
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[4], ARGV[5]); "
|
|
|
|
|
+ "redis.call('zadd', KEYS[2], ARGV[2], ARGV[4]); "
|
|
|
|
|
+ "msg = struct.pack('Lc0Lc0h', string.len(ARGV[4]), ARGV[4], string.len(ARGV[5]), ARGV[5], -1); "
|
|
|
|
|
+ "syncMsg = struct.pack('Lc0Lc0hd', string.len(ARGV[4]), ARGV[4], string.len(ARGV[5]), ARGV[5], -1, ARGV[6]); "
|
|
|
|
|
+ "else "
|
|
|
|
|
+ "local value = redis.call('hget', KEYS[1], ARGV[4]);"
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[4], ARGV[5]); "
|
|
|
|
|
+ "redis.call('zadd', KEYS[2], ARGV[2], ARGV[4]); "
|
|
|
|
|
+ "msg = struct.pack('Lc0Lc0Lc0', string.len(ARGV[4]), ARGV[4], string.len(ARGV[5]), ARGV[5], string.len(tostring(value)), tostring(value)); "
|
|
|
|
|
+ "syncMsg = struct.pack('Lc0Lc0Lc0d', string.len(ARGV[4]), ARGV[4], string.len(ARGV[5]), ARGV[5], string.len(tostring(value)), tostring(value), ARGV[6]); "
|
|
|
|
|
+ "end; "
|
|
|
|
@ -652,13 +665,15 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
|
|
|
|
|
+ "local syncs = redis.call('publish', KEYS[8], syncMsg); "
|
|
|
|
|
+ "return {1, syncs};"
|
|
|
|
|
+ "else "
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[4], ARGV[5]); "
|
|
|
|
|
+ "local oldValueRequired = tonumber(redis.call('get', KEYS[9])); "
|
|
|
|
|
+ "local msg, syncMsg; "
|
|
|
|
|
+ "if oldValueRequired == nil or oldValueRequired < 1 then "
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[4], ARGV[5]); "
|
|
|
|
|
+ "msg = struct.pack('Lc0Lc0h', string.len(ARGV[4]), ARGV[4], string.len(ARGV[5]), ARGV[5], -1); "
|
|
|
|
|
+ "syncMsg = struct.pack('Lc0Lc0hd', string.len(ARGV[4]), ARGV[4], string.len(ARGV[5]), ARGV[5], -1, ARGV[6]); "
|
|
|
|
|
+ "else "
|
|
|
|
|
+ "local value = redis.call('hget', KEYS[1], ARGV[4]);"
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[4], ARGV[5]); "
|
|
|
|
|
+ "msg = struct.pack('Lc0Lc0Lc0', string.len(ARGV[4]), ARGV[4], string.len(ARGV[5]), ARGV[5], string.len(tostring(value)), tostring(value)); "
|
|
|
|
|
+ "syncMsg = struct.pack('Lc0Lc0Lc0d', string.len(ARGV[4]), ARGV[4], string.len(ARGV[5]), ARGV[5], string.len(tostring(value)), tostring(value), ARGV[6]); "
|
|
|
|
|
+ "end; "
|
|
|
|
@ -2282,29 +2297,32 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
|
|
|
|
|
Long updateTimeout = getUpdateTimeout();
|
|
|
|
|
double syncId = ThreadLocalRandom.current().nextDouble();
|
|
|
|
|
Long syncs = evalWrite(getRawName(), codec, RedisCommands.EVAL_LONG,
|
|
|
|
|
"local value = redis.call('hget', KEYS[1], ARGV[4]); "
|
|
|
|
|
+ "if ARGV[2] == '0' then "
|
|
|
|
|
"if ARGV[2] == '0' then "
|
|
|
|
|
+ "redis.call('hdel', KEYS[1], ARGV[4]); "
|
|
|
|
|
+ "redis.call('zrem', KEYS[2], ARGV[4]); "
|
|
|
|
|
+ "local value = redis.call('hget', KEYS[1], ARGV[4]); "
|
|
|
|
|
+ "local msg = struct.pack('Lc0Lc0', string.len(ARGV[4]), ARGV[4], string.len(tostring(value)), tostring(value)); "
|
|
|
|
|
+ "redis.call('publish', KEYS[3], msg); "
|
|
|
|
|
+ "local syncMsg = struct.pack('Lc0Lc0d', string.len(ARGV[4]), ARGV[4], string.len(tostring(value)), tostring(value), ARGV[7]); "
|
|
|
|
|
+ "return redis.call('publish', KEYS[5], syncMsg); "
|
|
|
|
|
+ "elseif ARGV[2] ~= '-1' then "
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[4], ARGV[6]); "
|
|
|
|
|
+ "redis.call('zadd', KEYS[2], ARGV[2], ARGV[4]); "
|
|
|
|
|
+ "elseif ARGV[2] ~= '-1' then "
|
|
|
|
|
+ "local oldValueRequired = tonumber(redis.call('get', KEYS[7])); "
|
|
|
|
|
+ "local msg, syncMsg; "
|
|
|
|
|
+ "if oldValueRequired == nil or oldValueRequired < 1 then "
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[4], ARGV[6]); "
|
|
|
|
|
+ "redis.call('zadd', KEYS[2], ARGV[2], ARGV[4]); "
|
|
|
|
|
+ "msg = struct.pack('Lc0Lc0h', string.len(ARGV[4]), ARGV[4], string.len(ARGV[6]), ARGV[6], -1); "
|
|
|
|
|
+ "syncMsg = struct.pack('Lc0Lc0hd', string.len(ARGV[4]), ARGV[4], string.len(ARGV[6]), ARGV[6], -1, ARGV[7]); "
|
|
|
|
|
+ "else "
|
|
|
|
|
+ "local value = redis.call('hget', KEYS[1], ARGV[4]); "
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[4], ARGV[6]); "
|
|
|
|
|
+ "redis.call('zadd', KEYS[2], ARGV[2], ARGV[4]); "
|
|
|
|
|
+ "msg = struct.pack('Lc0Lc0Lc0', string.len(ARGV[4]), ARGV[4], string.len(ARGV[6]), ARGV[6], string.len(tostring(value)), tostring(value)); "
|
|
|
|
|
+ "syncMsg = struct.pack('Lc0Lc0Lc0d', string.len(ARGV[4]), ARGV[4], string.len(ARGV[6]), ARGV[6], string.len(tostring(value)), tostring(value), ARGV[7]); "
|
|
|
|
|
+ "end; "
|
|
|
|
|
+ "redis.call('publish', KEYS[4], msg); "
|
|
|
|
|
+ "return redis.call('publish', KEYS[6], syncMsg); "
|
|
|
|
|
+ "else "
|
|
|
|
|
+ "else "
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[4], ARGV[6]); "
|
|
|
|
|
+ "local msg = struct.pack('Lc0Lc0', string.len(ARGV[4]), ARGV[4], string.len(ARGV[6]), ARGV[6]); "
|
|
|
|
|
+ "redis.call('publish', KEYS[4], msg); "
|
|
|
|
@ -2497,36 +2515,41 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
|
|
|
|
|
double syncId = ThreadLocalRandom.current().nextDouble();
|
|
|
|
|
Long updateTimeout = getUpdateTimeout();
|
|
|
|
|
Long syncs = evalWrite(getRawName(), codec, RedisCommands.EVAL_LONG,
|
|
|
|
|
"local value = redis.call('hget', KEYS[1], ARGV[3]); "
|
|
|
|
|
+ "if ARGV[1] == '0' then "
|
|
|
|
|
"if ARGV[1] == '0' then "
|
|
|
|
|
+ "redis.call('hdel', KEYS[1], ARGV[3]); "
|
|
|
|
|
+ "redis.call('zrem', KEYS[2], ARGV[3]); "
|
|
|
|
|
+ "local value = redis.call('hget', KEYS[1], ARGV[3]); "
|
|
|
|
|
+ "local msg = struct.pack('Lc0Lc0', string.len(ARGV[3]), ARGV[3], string.len(tostring(value)), tostring(value)); "
|
|
|
|
|
+ "redis.call('publish', KEYS[3], msg); "
|
|
|
|
|
+ "local syncMsg = struct.pack('Lc0Lc0d', string.len(ARGV[3]), ARGV[3], string.len(tostring(value)), tostring(value), ARGV[5]); "
|
|
|
|
|
+ "return redis.call('publish', KEYS[5], syncMsg); "
|
|
|
|
|
+ "elseif ARGV[1] ~= '-1' then "
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[3], ARGV[4]); "
|
|
|
|
|
+ "redis.call('zadd', KEYS[2], ARGV[1], ARGV[3]); "
|
|
|
|
|
+ "local oldValueRequired = tonumber(redis.call('get', KEYS[7])); "
|
|
|
|
|
+ "local msg, syncMsg; "
|
|
|
|
|
+ "if oldValueRequired == nil or oldValueRequired < 1 then "
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[3], ARGV[4]); "
|
|
|
|
|
+ "redis.call('zadd', KEYS[2], ARGV[1], ARGV[3]); "
|
|
|
|
|
+ "msg = struct.pack('Lc0Lc0h', string.len(ARGV[3]), ARGV[3], string.len(ARGV[4]), ARGV[4], -1); "
|
|
|
|
|
+ "syncMsg = struct.pack('Lc0Lc0hd', string.len(ARGV[3]), ARGV[3], string.len(ARGV[4]), ARGV[4], -1, ARGV[5]); "
|
|
|
|
|
+ "else "
|
|
|
|
|
+ "local value = redis.call('hget', KEYS[1], ARGV[3]); "
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[3], ARGV[4]); "
|
|
|
|
|
+ "redis.call('zadd', KEYS[2], ARGV[1], ARGV[3]); "
|
|
|
|
|
+ "msg = struct.pack('Lc0Lc0Lc0', string.len(ARGV[3]), ARGV[3], string.len(ARGV[4]), ARGV[4], string.len(tostring(value)), tostring(value)); "
|
|
|
|
|
+ "syncMsg = struct.pack('Lc0Lc0Lc0d', string.len(ARGV[3]), ARGV[3], string.len(ARGV[4]), ARGV[4], string.len(tostring(value)), tostring(value), ARGV[5]); "
|
|
|
|
|
+ "end; "
|
|
|
|
|
+ "redis.call('publish', KEYS[4], msg); "
|
|
|
|
|
+ "return redis.call('publish', KEYS[6], syncMsg); "
|
|
|
|
|
+ "else "
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[3], ARGV[4]); "
|
|
|
|
|
+ "else "
|
|
|
|
|
+ "local oldValueRequired = tonumber(redis.call('get', KEYS[7])); "
|
|
|
|
|
+ "local msg, syncMsg; "
|
|
|
|
|
+ "if oldValueRequired == nil or oldValueRequired < 1 then "
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[3], ARGV[4]); "
|
|
|
|
|
+ "msg = struct.pack('Lc0Lc0h', string.len(ARGV[3]), ARGV[3], string.len(ARGV[4]), ARGV[4], -1); "
|
|
|
|
|
+ "syncMsg = struct.pack('Lc0Lc0hd', string.len(ARGV[3]), ARGV[3], string.len(ARGV[4]), ARGV[4], -1, ARGV[5]); "
|
|
|
|
|
+ "else "
|
|
|
|
|
+ "local value = redis.call('hget', KEYS[1], ARGV[3]); "
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[3], ARGV[4]); "
|
|
|
|
|
+ "msg = struct.pack('Lc0Lc0Lc0', string.len(ARGV[3]), ARGV[3], string.len(ARGV[4]), ARGV[4], string.len(tostring(value)), tostring(value)); "
|
|
|
|
|
+ "syncMsg = struct.pack('Lc0Lc0Lc0d', string.len(ARGV[3]), ARGV[3], string.len(ARGV[4]), ARGV[4], string.len(tostring(value)), tostring(value), ARGV[5]); "
|
|
|
|
|
+ "end; "
|
|
|
|
@ -2660,36 +2683,41 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
|
|
|
|
|
Long updateTimeout = getUpdateTimeout();
|
|
|
|
|
double syncId = ThreadLocalRandom.current().nextDouble();
|
|
|
|
|
Long syncs = evalWrite(getRawName(), codec, RedisCommands.EVAL_LONG,
|
|
|
|
|
"local value = redis.call('hget', KEYS[1], ARGV[3]); "
|
|
|
|
|
+ "if ARGV[1] == '0' then "
|
|
|
|
|
"if ARGV[1] == '0' then "
|
|
|
|
|
+ "redis.call('hdel', KEYS[1], ARGV[3]); "
|
|
|
|
|
+ "redis.call('zrem', KEYS[2], ARGV[3]); "
|
|
|
|
|
+ "local value = redis.call('hget', KEYS[1], ARGV[3]); "
|
|
|
|
|
+ "local msg = struct.pack('Lc0Lc0', string.len(ARGV[3]), ARGV[3], string.len(tostring(value)), tostring(value)); "
|
|
|
|
|
+ "redis.call('publish', KEYS[3], msg); "
|
|
|
|
|
+ "local syncMsg = struct.pack('Lc0Lc0d', string.len(ARGV[3]), ARGV[3], string.len(tostring(value)), tostring(value), ARGV[5]); "
|
|
|
|
|
+ "return redis.call('publish', KEYS[5], msg); "
|
|
|
|
|
+ "elseif ARGV[1] ~= '-1' then "
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[3], ARGV[4]); "
|
|
|
|
|
+ "redis.call('zadd', KEYS[2], ARGV[1], ARGV[3]); "
|
|
|
|
|
+ "elseif ARGV[1] ~= '-1' then "
|
|
|
|
|
+ "local oldValueRequired = tonumber(redis.call('get', KEYS[7])); "
|
|
|
|
|
+ "local msg, syncMsg; "
|
|
|
|
|
+ "if oldValueRequired == nil or oldValueRequired < 1 then "
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[3], ARGV[4]); "
|
|
|
|
|
+ "redis.call('zadd', KEYS[2], ARGV[1], ARGV[3]); "
|
|
|
|
|
+ "msg = struct.pack('Lc0Lc0h', string.len(ARGV[3]), ARGV[3], string.len(ARGV[4]), ARGV[4], -1); "
|
|
|
|
|
+ "syncMsg = struct.pack('Lc0Lc0hd', string.len(ARGV[3]), ARGV[3], string.len(ARGV[4]), ARGV[4], -1, ARGV[5]); "
|
|
|
|
|
+ "else "
|
|
|
|
|
+ "local value = redis.call('hget', KEYS[1], ARGV[3]); "
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[3], ARGV[4]); "
|
|
|
|
|
+ "redis.call('zadd', KEYS[2], ARGV[1], ARGV[3]); "
|
|
|
|
|
+ "msg = struct.pack('Lc0Lc0Lc0', string.len(ARGV[3]), ARGV[3], string.len(ARGV[4]), ARGV[4], string.len(tostring(value)), tostring(value)); "
|
|
|
|
|
+ "syncMsg = struct.pack('Lc0Lc0Lc0d', string.len(ARGV[3]), ARGV[3], string.len(ARGV[4]), ARGV[4], string.len(tostring(value)), tostring(value), ARGV[5]); "
|
|
|
|
|
+ "end; "
|
|
|
|
|
+ "redis.call('publish', KEYS[4], msg); "
|
|
|
|
|
+ "return redis.call('publish', KEYS[6], syncMsg); "
|
|
|
|
|
+ "else "
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[3], ARGV[4]); "
|
|
|
|
|
+ "else "
|
|
|
|
|
+ "local oldValueRequired = tonumber(redis.call('get', KEYS[7])); "
|
|
|
|
|
+ "local msg, syncMsg; "
|
|
|
|
|
+ "if oldValueRequired == nil or oldValueRequired < 1 then "
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[3], ARGV[4]); "
|
|
|
|
|
+ "msg = struct.pack('Lc0Lc0h', string.len(ARGV[3]), ARGV[3], string.len(ARGV[4]), ARGV[4], -1); "
|
|
|
|
|
+ "syncMsg = struct.pack('Lc0Lc0hd', string.len(ARGV[3]), ARGV[3], string.len(ARGV[4]), ARGV[4], -1, ARGV[5]); "
|
|
|
|
|
+ "else "
|
|
|
|
|
+ "local value = redis.call('hget', KEYS[1], ARGV[3]); "
|
|
|
|
|
+ "redis.call('hset', KEYS[1], ARGV[3], ARGV[4]); "
|
|
|
|
|
+ "msg = struct.pack('Lc0Lc0Lc0', string.len(ARGV[3]), ARGV[3], string.len(ARGV[4]), ARGV[4], string.len(tostring(value)), tostring(value)); "
|
|
|
|
|
+ "syncMsg = struct.pack('Lc0Lc0Lc0d', string.len(ARGV[3]), ARGV[3], string.len(ARGV[4]), ARGV[4], string.len(tostring(value)), tostring(value), ARGV[5]); "
|
|
|
|
|
+ "end; "
|
|
|
|
|