mock_redis 0.54.0 → 0.55.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/mock_redis/version.rb +1 -1
- data/lib/mock_redis/zset_methods.rb +53 -0
- metadata +9 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f61c25ac91aa99558a90e5035269dbabc36c565d7aec85e78356a2178c5aa1a6
|
|
4
|
+
data.tar.gz: bdb253307125c9dc1418bc11ea5884e36d4d0e425b8243c3619816b3cc91cd48
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 40e400a1c118712a11c638e26cdc1ce0e10cb70e34c8a390c94e904a94d1141cd152167fa465ff5e78f8c4cf31e9eeb02efc568211dbd83ae4c18a87917d61ba
|
|
7
|
+
data.tar.gz: d68b5609c754e1c1dc0a90433e25d22466cf1a88f9733a90e8aa3daa2abe2a389b80ed32ef0daa27fd8952d2ce6c0baa80e0f28c2edb887d4e749d6b6a258689
|
data/CHANGELOG.md
CHANGED
data/lib/mock_redis/version.rb
CHANGED
|
@@ -18,6 +18,13 @@ class MockRedis
|
|
|
18
18
|
)
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
+
if zadd_options&.include?(:gt) && zadd_options&.include?(:nx)
|
|
22
|
+
raise Error.command_error(
|
|
23
|
+
'ERR GT, LT, and/or NX options at the same time are not compatible',
|
|
24
|
+
self
|
|
25
|
+
)
|
|
26
|
+
end
|
|
27
|
+
|
|
21
28
|
if args.size == 1 && args[0].is_a?(Array)
|
|
22
29
|
zadd_multiple_members(key, args.first, zadd_options)
|
|
23
30
|
elsif args.size == 2
|
|
@@ -33,6 +40,24 @@ class MockRedis
|
|
|
33
40
|
|
|
34
41
|
with_zset_at(key) do |zset|
|
|
35
42
|
if zadd_options[:incr]
|
|
43
|
+
if zadd_options[:gt]
|
|
44
|
+
current_score = zset.score(member.to_s)
|
|
45
|
+
|
|
46
|
+
# NOTE: does nothing if the member doesn't exist and XX option is set.
|
|
47
|
+
return nil if current_score.nil? && zadd_options[:xx]
|
|
48
|
+
|
|
49
|
+
# NOTE: zincrby add the increment if the member doesn't exist and XX option is not set.
|
|
50
|
+
return zincrby(key, score, member) if current_score.nil? && !zadd_options[:xx]
|
|
51
|
+
|
|
52
|
+
new_score = current_score + score.to_f
|
|
53
|
+
|
|
54
|
+
# NOTE: does nothing if the new score is not greater than the current score.
|
|
55
|
+
return nil if current_score && new_score <= current_score
|
|
56
|
+
|
|
57
|
+
# NOTE: zincrby update the score if the new score is greater than the current score.
|
|
58
|
+
return zincrby(key, score, member)
|
|
59
|
+
end
|
|
60
|
+
|
|
36
61
|
if zadd_options[:xx]
|
|
37
62
|
member_present = zset.include?(member)
|
|
38
63
|
return member_present ? zincrby(key, score, member) : nil
|
|
@@ -44,7 +69,21 @@ class MockRedis
|
|
|
44
69
|
end
|
|
45
70
|
|
|
46
71
|
zincrby(key, score, member)
|
|
72
|
+
elsif zadd_options[:gt]
|
|
73
|
+
current_score = zset.score(member.to_s)
|
|
74
|
+
new_score = score.to_f
|
|
75
|
+
|
|
76
|
+
if current_score.nil?
|
|
77
|
+
return false if zadd_options[:xx]
|
|
78
|
+
|
|
79
|
+
zset.add(new_score, member.to_s)
|
|
80
|
+
true
|
|
81
|
+
else
|
|
82
|
+
zset.add(new_score, member.to_s) if new_score > current_score
|
|
83
|
+
false
|
|
84
|
+
end
|
|
47
85
|
elsif zadd_options[:xx]
|
|
86
|
+
# NOTE: gt and xx options are handled at the gt branch above, so its not handled here.
|
|
48
87
|
zset.add(score, member.to_s) if zset.include?(member)
|
|
49
88
|
false
|
|
50
89
|
elsif zadd_options[:nx]
|
|
@@ -67,6 +106,20 @@ class MockRedis
|
|
|
67
106
|
'ERR INCR option supports a single increment-element pair',
|
|
68
107
|
self
|
|
69
108
|
)
|
|
109
|
+
elsif zadd_options[:gt]
|
|
110
|
+
args.reduce(0) do |retval, (score, member)|
|
|
111
|
+
current_score = zset.score(member.to_s)
|
|
112
|
+
if current_score.nil?
|
|
113
|
+
unless zadd_options[:xx]
|
|
114
|
+
zset.add(score.to_f, member.to_s)
|
|
115
|
+
retval += 1
|
|
116
|
+
end
|
|
117
|
+
else
|
|
118
|
+
score_f = score.to_f
|
|
119
|
+
zset.add(score_f, member.to_s) if score_f > current_score
|
|
120
|
+
end
|
|
121
|
+
retval
|
|
122
|
+
end
|
|
70
123
|
elsif zadd_options[:xx]
|
|
71
124
|
args.each { |score, member| zset.include?(member) && zset.add(score, member.to_s) }
|
|
72
125
|
0
|
metadata
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mock_redis
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.55.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shane da Silva
|
|
8
8
|
- Samuel Merritt
|
|
9
|
+
autorequire:
|
|
9
10
|
bindir: bin
|
|
10
11
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
+
date: 2026-06-04 00:00:00.000000000 Z
|
|
12
13
|
dependencies:
|
|
13
14
|
- !ruby/object:Gem::Dependency
|
|
14
15
|
name: redis
|
|
@@ -124,10 +125,11 @@ licenses:
|
|
|
124
125
|
- MIT
|
|
125
126
|
metadata:
|
|
126
127
|
bug_tracker_uri: https://github.com/sds/mock_redis/issues
|
|
127
|
-
changelog_uri: https://github.com/sds/mock_redis/blob/v0.
|
|
128
|
-
documentation_uri: https://www.rubydoc.info/gems/mock_redis/0.
|
|
128
|
+
changelog_uri: https://github.com/sds/mock_redis/blob/v0.55.0/CHANGELOG.md
|
|
129
|
+
documentation_uri: https://www.rubydoc.info/gems/mock_redis/0.55.0
|
|
129
130
|
homepage_uri: https://github.com/sds/mock_redis
|
|
130
|
-
source_code_uri: https://github.com/sds/mock_redis/tree/v0.
|
|
131
|
+
source_code_uri: https://github.com/sds/mock_redis/tree/v0.55.0
|
|
132
|
+
post_install_message:
|
|
131
133
|
rdoc_options: []
|
|
132
134
|
require_paths:
|
|
133
135
|
- lib
|
|
@@ -142,7 +144,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
142
144
|
- !ruby/object:Gem::Version
|
|
143
145
|
version: '0'
|
|
144
146
|
requirements: []
|
|
145
|
-
rubygems_version: 3.
|
|
147
|
+
rubygems_version: 3.0.3.1
|
|
148
|
+
signing_key:
|
|
146
149
|
specification_version: 4
|
|
147
150
|
summary: Redis mock that just lives in memory; useful for testing.
|
|
148
151
|
test_files: []
|