mm_redis 2.1.7 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/example/index.js +40 -0
- package/index.js +12 -4112
- package/lib/redis.js +4085 -0
- package/lib/tools/index.js +16 -0
- package/lib/tools/push_queue/index.js +115 -0
- package/lib/tools/queue/index.js +395 -0
- package/lib/tools/redis/index.js +57 -0
- package/lib/tools/redis_lock/index.js +210 -0
- package/package.json +49 -39
- package/test.js +14 -1
- package/tool/push_queue/index.js +7 -0
- package/tool/push_queue/tool.json +56 -0
- package/tool/queue/index.js +7 -0
- package/tool/queue/tool.json +129 -0
- package/tool/redis/index.js +7 -0
- package/tool/redis/tool.json +133 -0
- package/tool/redis_lock/index.js +7 -0
- package/tool/redis_lock/tool.json +91 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "redis_lock",
|
|
3
|
+
"handler": "manager",
|
|
4
|
+
"title": "Redis分布式锁",
|
|
5
|
+
"description": "基于 Redis 的分布式锁,支持获取、释放、续期,防过期误删。适用场景:多实例并发互斥访问共享资源时。工作流提示:action 选 acquire/release/renew,lock_key 必填,release/renew 回传 acquire 的 lock_value,ttl 设秒数,获取在 acquired。",
|
|
6
|
+
"type": "data",
|
|
7
|
+
"params": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"action": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "操作类型: acquire/release/renew",
|
|
13
|
+
"enum": [
|
|
14
|
+
"acquire",
|
|
15
|
+
"release",
|
|
16
|
+
"renew"
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
"lock_key": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"description": "锁键名,建议格式: lock:业务:资源ID"
|
|
22
|
+
},
|
|
23
|
+
"lock_value": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "锁值(release/renew时必填,需与acquire返回的lock_value一致)"
|
|
26
|
+
},
|
|
27
|
+
"ttl": {
|
|
28
|
+
"type": "number",
|
|
29
|
+
"description": "锁过期时间(秒),默认30秒"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"required": [
|
|
33
|
+
"action",
|
|
34
|
+
"lock_key"
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
"returns": {
|
|
38
|
+
"description": "锁操作结果,acquire返回lock_value用于后续释放/续期",
|
|
39
|
+
"type": "object",
|
|
40
|
+
"properties": {
|
|
41
|
+
"acquired": {
|
|
42
|
+
"type": "boolean",
|
|
43
|
+
"description": "是否获取锁成功(acquire操作)"
|
|
44
|
+
},
|
|
45
|
+
"released": {
|
|
46
|
+
"type": "boolean",
|
|
47
|
+
"description": "是否释放锁成功(release操作)"
|
|
48
|
+
},
|
|
49
|
+
"renewed": {
|
|
50
|
+
"type": "boolean",
|
|
51
|
+
"description": "是否续期成功(renew操作)"
|
|
52
|
+
},
|
|
53
|
+
"lock_key": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"description": "锁键名"
|
|
56
|
+
},
|
|
57
|
+
"lock_value": {
|
|
58
|
+
"type": "string",
|
|
59
|
+
"description": "锁唯一标识(acquire时返回,用于后续释放/续期)"
|
|
60
|
+
},
|
|
61
|
+
"ttl": {
|
|
62
|
+
"type": "number",
|
|
63
|
+
"description": "锁过期时间(秒)"
|
|
64
|
+
},
|
|
65
|
+
"msg": {
|
|
66
|
+
"type": "string",
|
|
67
|
+
"description": "操作结果描述"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"options": {
|
|
72
|
+
"host": {
|
|
73
|
+
"type": "string",
|
|
74
|
+
"description": "Redis 主机",
|
|
75
|
+
"default": "localhost"
|
|
76
|
+
},
|
|
77
|
+
"port": {
|
|
78
|
+
"type": "number",
|
|
79
|
+
"description": "Redis 端口"
|
|
80
|
+
},
|
|
81
|
+
"password": {
|
|
82
|
+
"type": "string",
|
|
83
|
+
"description": "Redis 密码"
|
|
84
|
+
},
|
|
85
|
+
"db": {
|
|
86
|
+
"type": "number",
|
|
87
|
+
"description": "Redis 数据库编号"
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
"group": "system"
|
|
91
|
+
}
|