Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_57962205
redisson
提交
488e89a7
R
redisson
项目概览
weixin_57962205
/
redisson
与 Fork 源项目一致
从无法访问的项目Fork
通知
10
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redisson
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
488e89a7
编写于
4月 12, 2021
作者:
T
Tom Erik Støwer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Call hget only when needed
Signed-off-by:
N
Tom Erik Støwer
<
testower@gmail.com
>
上级
5b241213
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
60 addition
and
32 deletion
+60
-32
redisson/src/main/java/org/redisson/jcache/JCache.java
redisson/src/main/java/org/redisson/jcache/JCache.java
+60
-32
未找到文件。
redisson/src/main/java/org/redisson/jcache/JCache.java
浏览文件 @
488e89a7
...
@@ -392,24 +392,27 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
...
@@ -392,24 +392,27 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
if
(
containsKey
(
key
))
{
if
(
containsKey
(
key
))
{
Long
updateTimeout
=
getUpdateTimeout
();
Long
updateTimeout
=
getUpdateTimeout
();
List
<
Object
>
res
=
evalWrite
(
getRawName
(),
codec
,
RedisCommands
.
EVAL_LIST
,
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('hdel', KEYS[1], ARGV[4]); "
+
"redis.call('zrem', KEYS[2], 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)); "
+
"local msg = struct.pack('Lc0Lc0', string.len(ARGV[4]), ARGV[4], string.len(tostring(value)), tostring(value)); "
+
"redis.call('publish', KEYS[4], msg); "
+
"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 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); "
+
"local syncs = redis.call('publish', KEYS[7], syncMsg); "
+
"return {0, syncs};"
+
"return {0, syncs};"
+
"elseif ARGV[2] ~= '-1' then "
+
"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 oldValueRequired = tonumber(redis.call('get', KEYS[9])); "
+
"local msg, syncMsg; "
+
"local msg, syncMsg; "
+
"if oldValueRequired == nil or oldValueRequired < 1 then "
+
"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); "
+
"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]); "
+
"syncMsg = struct.pack('Lc0Lc0hd', string.len(ARGV[4]), ARGV[4], string.len(ARGV[5]), ARGV[5], -1, ARGV[6]); "
+
"else "
+
"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)); "
+
"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]); "
+
"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; "
+
"end; "
...
@@ -417,13 +420,15 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
...
@@ -417,13 +420,15 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
+
"local syncs = redis.call('publish', KEYS[8], syncMsg); "
+
"local syncs = redis.call('publish', KEYS[8], syncMsg); "
+
"return {1, syncs};"
+
"return {1, syncs};"
+
"else "
+
"else "
+
"redis.call('hset', KEYS[1], ARGV[4], ARGV[5]); "
+
"local oldValueRequired = tonumber(redis.call('get', KEYS[9])); "
+
"local oldValueRequired = tonumber(redis.call('get', KEYS[9])); "
+
"local msg, syncMsg; "
+
"local msg, syncMsg; "
+
"if oldValueRequired == nil or oldValueRequired < 1 then "
+
"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); "
+
"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]); "
+
"syncMsg = struct.pack('Lc0Lc0hd', string.len(ARGV[4]), ARGV[4], string.len(ARGV[5]), ARGV[5], -1, ARGV[6]); "
+
"else "
+
"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)); "
+
"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]); "
+
"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; "
+
"end; "
...
@@ -500,23 +505,26 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
...
@@ -500,23 +505,26 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
"exists = false;"
+
"exists = false;"
+
"end;"
+
"end;"
+
"if exists then "
"if exists then "
+
"local value = redis.call('hget', KEYS[1], ARGV[i]);"
+
"if ARGV[2] == '0' then "
+
"if ARGV[2] == '0' then "
+
"redis.call('hdel', KEYS[1], ARGV[i]); "
+
"redis.call('hdel', KEYS[1], ARGV[i]); "
+
"redis.call('zrem', KEYS[2], 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)); "
+
"local msg = struct.pack('Lc0Lc0', string.len(ARGV[i]), ARGV[i], string.len(tostring(value)), tostring(value)); "
+
"redis.call('publish', KEYS[4], msg); "
+
"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]); "
+
"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); "
+
"syncs = syncs + redis.call('publish', KEYS[7], syncMsg); "
+
"elseif ARGV[2] ~= '-1' then "
+
"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 oldValueRequired = tonumber(redis.call('get', KEYS[9])); "
+
"local msg, syncMsg; "
+
"local msg, syncMsg; "
+
"if oldValueRequired == nil or oldValueRequired < 1 then "
+
"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); "
+
"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]); "
+
"syncMsg = struct.pack('Lc0Lc0hd', string.len(ARGV[i]), ARGV[i], string.len(ARGV[i+1]), ARGV[i+1], -1, ARGV[4]); "
+
"else "
+
"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)); "
+
"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]); "
+
"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; "
+
"end; "
...
@@ -524,13 +532,15 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
...
@@ -524,13 +532,15 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
+
"syncs = syncs + redis.call('publish', KEYS[8], syncMsg); "
+
"syncs = syncs + redis.call('publish', KEYS[8], syncMsg); "
+
"added = added + 1;"
+
"added = added + 1;"
+
"else "
+
"else "
+
"redis.call('hset', KEYS[1], ARGV[i], ARGV[i+1]); "
+
"local oldValueRequired = tonumber(redis.call('get', KEYS[9])); "
+
"local oldValueRequired = tonumber(redis.call('get', KEYS[9])); "
+
"local msg, syncMsg; "
+
"local msg, syncMsg; "
+
"if oldValueRequired == nil or oldValueRequired < 1 then "
+
"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); "
+
"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]); "
+
"syncMsg = struct.pack('Lc0Lc0hd', string.len(ARGV[i]), ARGV[i], string.len(ARGV[i+1]), ARGV[i+1], -1, ARGV[4]); "
+
"else "
+
"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)); "
+
"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]); "
+
"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; "
+
"end; "
...
@@ -627,24 +637,27 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
...
@@ -627,24 +637,27 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
"exists = false;"
+
"exists = false;"
+
"end;"
+
"end;"
+
"if exists then "
"if exists then "
+
"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('hdel', KEYS[1], ARGV[4]); "
+
"redis.call('zrem', KEYS[2], 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)); "
+
"local msg = struct.pack('Lc0Lc0', string.len(ARGV[4]), ARGV[4], string.len(tostring(value)), tostring(value)); "
+
"redis.call('publish', KEYS[4], msg); "
+
"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 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); "
+
"local syncs = redis.call('publish', KEYS[7], syncMsg); "
+
"return {0, syncs};"
+
"return {0, syncs};"
+
"elseif ARGV[2] ~= '-1' then "
+
"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 oldValueRequired = tonumber(redis.call('get', KEYS[9])); "
+
"local msg, syncMsg; "
+
"local msg, syncMsg; "
+
"if oldValueRequired == nil or oldValueRequired < 1 then "
+
"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); "
+
"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]); "
+
"syncMsg = struct.pack('Lc0Lc0hd', string.len(ARGV[4]), ARGV[4], string.len(ARGV[5]), ARGV[5], -1, ARGV[6]); "
+
"else "
+
"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)); "
+
"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]); "
+
"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; "
+
"end; "
...
@@ -652,13 +665,15 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
...
@@ -652,13 +665,15 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
+
"local syncs = redis.call('publish', KEYS[8], syncMsg); "
+
"local syncs = redis.call('publish', KEYS[8], syncMsg); "
+
"return {1, syncs};"
+
"return {1, syncs};"
+
"else "
+
"else "
+
"redis.call('hset', KEYS[1], ARGV[4], ARGV[5]); "
+
"local oldValueRequired = tonumber(redis.call('get', KEYS[9])); "
+
"local oldValueRequired = tonumber(redis.call('get', KEYS[9])); "
+
"local msg, syncMsg; "
+
"local msg, syncMsg; "
+
"if oldValueRequired == nil or oldValueRequired < 1 then "
+
"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); "
+
"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]); "
+
"syncMsg = struct.pack('Lc0Lc0hd', string.len(ARGV[4]), ARGV[4], string.len(ARGV[5]), ARGV[5], -1, ARGV[6]); "
+
"else "
+
"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)); "
+
"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]); "
+
"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; "
+
"end; "
...
@@ -2282,29 +2297,32 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
...
@@ -2282,29 +2297,32 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
Long
updateTimeout
=
getUpdateTimeout
();
Long
updateTimeout
=
getUpdateTimeout
();
double
syncId
=
ThreadLocalRandom
.
current
().
nextDouble
();
double
syncId
=
ThreadLocalRandom
.
current
().
nextDouble
();
Long
syncs
=
evalWrite
(
getRawName
(),
codec
,
RedisCommands
.
EVAL_LONG
,
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('hdel', KEYS[1], ARGV[4]); "
+
"redis.call('zrem', KEYS[2], 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)); "
+
"local msg = struct.pack('Lc0Lc0', string.len(ARGV[4]), ARGV[4], string.len(tostring(value)), tostring(value)); "
+
"redis.call('publish', KEYS[3], msg); "
+
"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]); "
+
"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); "
+
"return redis.call('publish', KEYS[5], syncMsg); "
+
"elseif ARGV[2] ~= '-1' then "
+
"elseif ARGV[2] ~= '-1' then "
+
"redis.call('hset', KEYS[1], ARGV[4], ARGV[6]); "
+
"redis.call('zadd', KEYS[2], ARGV[2], ARGV[4]); "
+
"local oldValueRequired = tonumber(redis.call('get', KEYS[7])); "
+
"local oldValueRequired = tonumber(redis.call('get', KEYS[7])); "
+
"local msg, syncMsg; "
+
"local msg, syncMsg; "
+
"if oldValueRequired == nil or oldValueRequired < 1 then "
+
"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); "
+
"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]); "
+
"syncMsg = struct.pack('Lc0Lc0hd', string.len(ARGV[4]), ARGV[4], string.len(ARGV[6]), ARGV[6], -1, ARGV[7]); "
+
"else "
+
"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)); "
+
"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]); "
+
"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; "
+
"end; "
+
"redis.call('publish', KEYS[4], msg); "
+
"redis.call('publish', KEYS[4], msg); "
+
"return redis.call('publish', KEYS[6], syncMsg); "
+
"return redis.call('publish', KEYS[6], syncMsg); "
+
"else "
+
"else "
+
"redis.call('hset', KEYS[1], ARGV[4], ARGV[6]); "
+
"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]); "
+
"local msg = struct.pack('Lc0Lc0', string.len(ARGV[4]), ARGV[4], string.len(ARGV[6]), ARGV[6]); "
+
"redis.call('publish', KEYS[4], msg); "
+
"redis.call('publish', KEYS[4], msg); "
...
@@ -2497,36 +2515,41 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
...
@@ -2497,36 +2515,41 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
double
syncId
=
ThreadLocalRandom
.
current
().
nextDouble
();
double
syncId
=
ThreadLocalRandom
.
current
().
nextDouble
();
Long
updateTimeout
=
getUpdateTimeout
();
Long
updateTimeout
=
getUpdateTimeout
();
Long
syncs
=
evalWrite
(
getRawName
(),
codec
,
RedisCommands
.
EVAL_LONG
,
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('hdel', KEYS[1], ARGV[3]); "
+
"redis.call('zrem', KEYS[2], 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)); "
+
"local msg = struct.pack('Lc0Lc0', string.len(ARGV[3]), ARGV[3], string.len(tostring(value)), tostring(value)); "
+
"redis.call('publish', KEYS[3], msg); "
+
"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]); "
+
"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); "
+
"return redis.call('publish', KEYS[5], syncMsg); "
+
"elseif ARGV[1] ~= '-1' then "
+
"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 oldValueRequired = tonumber(redis.call('get', KEYS[7])); "
+
"local msg, syncMsg; "
+
"local msg, syncMsg; "
+
"if oldValueRequired == nil or oldValueRequired < 1 then "
+
"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); "
+
"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]); "
+
"syncMsg = struct.pack('Lc0Lc0hd', string.len(ARGV[3]), ARGV[3], string.len(ARGV[4]), ARGV[4], -1, ARGV[5]); "
+
"else "
+
"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)); "
+
"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]); "
+
"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; "
+
"end; "
+
"redis.call('publish', KEYS[4], msg); "
+
"redis.call('publish', KEYS[4], msg); "
+
"return redis.call('publish', KEYS[6], syncMsg); "
+
"return redis.call('publish', KEYS[6], syncMsg); "
+
"else "
+
"else "
+
"redis.call('hset', KEYS[1], ARGV[3], ARGV[4]); "
+
"local oldValueRequired = tonumber(redis.call('get', KEYS[7])); "
+
"local oldValueRequired = tonumber(redis.call('get', KEYS[7])); "
+
"local msg, syncMsg; "
+
"local msg, syncMsg; "
+
"if oldValueRequired == nil or oldValueRequired < 1 then "
+
"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); "
+
"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]); "
+
"syncMsg = struct.pack('Lc0Lc0hd', string.len(ARGV[3]), ARGV[3], string.len(ARGV[4]), ARGV[4], -1, ARGV[5]); "
+
"else "
+
"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)); "
+
"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]); "
+
"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; "
+
"end; "
...
@@ -2660,36 +2683,41 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
...
@@ -2660,36 +2683,41 @@ public class JCache<K, V> extends RedissonObject implements Cache<K, V>, CacheAs
Long
updateTimeout
=
getUpdateTimeout
();
Long
updateTimeout
=
getUpdateTimeout
();
double
syncId
=
ThreadLocalRandom
.
current
().
nextDouble
();
double
syncId
=
ThreadLocalRandom
.
current
().
nextDouble
();
Long
syncs
=
evalWrite
(
getRawName
(),
codec
,
RedisCommands
.
EVAL_LONG
,
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('hdel', KEYS[1], ARGV[3]); "
+
"redis.call('zrem', KEYS[2], 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)); "
+
"local msg = struct.pack('Lc0Lc0', string.len(ARGV[3]), ARGV[3], string.len(tostring(value)), tostring(value)); "
+
"redis.call('publish', KEYS[3], msg); "
+
"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]); "
+
"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); "
+
"return redis.call('publish', KEYS[5], msg); "
+
"elseif ARGV[1] ~= '-1' then "
+
"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 oldValueRequired = tonumber(redis.call('get', KEYS[7])); "
+
"local msg, syncMsg; "
+
"local msg, syncMsg; "
+
"if oldValueRequired == nil or oldValueRequired < 1 then "
+
"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); "
+
"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]); "
+
"syncMsg = struct.pack('Lc0Lc0hd', string.len(ARGV[3]), ARGV[3], string.len(ARGV[4]), ARGV[4], -1, ARGV[5]); "
+
"else "
+
"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)); "
+
"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]); "
+
"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; "
+
"end; "
+
"redis.call('publish', KEYS[4], msg); "
+
"redis.call('publish', KEYS[4], msg); "
+
"return redis.call('publish', KEYS[6], syncMsg); "
+
"return redis.call('publish', KEYS[6], syncMsg); "
+
"else "
+
"else "
+
"redis.call('hset', KEYS[1], ARGV[3], ARGV[4]); "
+
"local oldValueRequired = tonumber(redis.call('get', KEYS[7])); "
+
"local oldValueRequired = tonumber(redis.call('get', KEYS[7])); "
+
"local msg, syncMsg; "
+
"local msg, syncMsg; "
+
"if oldValueRequired == nil or oldValueRequired < 1 then "
+
"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); "
+
"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]); "
+
"syncMsg = struct.pack('Lc0Lc0hd', string.len(ARGV[3]), ARGV[3], string.len(ARGV[4]), ARGV[4], -1, ARGV[5]); "
+
"else "
+
"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)); "
+
"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]); "
+
"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; "
+
"end; "
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录