fakeredis 0.9.0 → 0.9.1
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/.github/workflows/ruby.yml +1 -1
- data/README.md +1 -1
- data/lib/fakeredis/geo_commands.rb +1 -1
- data/lib/fakeredis/version.rb +1 -1
- data/lib/redis/connection/memory.rb +20 -22
- data/spec/sets_spec.rb +2 -2
- data/spec/sorted_sets_spec.rb +2 -2
- data/spec/spec_helper.rb +3 -0
- data/spec/transactions_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f5bfa00feb72f7ffcaa7a1b0c2f316fe6f0e83c1a1e5d68f09f6243aeadca14
|
4
|
+
data.tar.gz: 8c31af643286808f7226f138278673d4523d9ef2fdf39a67336519d762ea9385
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5164767bdeed993d36fdaf7410c8a79d933b1e3d3958437e5346b080c5ac1c3f78b0f0a4ba77f9438a84f5480cd9f1629aead81e58c1bb9999a258009a944eff
|
7
|
+
data.tar.gz: d337bec1b6a2d54dfa96686cc177ce3c15b660205f8d5c71f7e0b52bee9a40909642604dd70b975755ede946091bc55fec82d644c82df02f2305e0e2d27e630b
|
data/.github/workflows/ruby.yml
CHANGED
@@ -22,7 +22,7 @@ jobs:
|
|
22
22
|
fail-fast: false
|
23
23
|
matrix:
|
24
24
|
os: [ubuntu, macos]
|
25
|
-
ruby: [3.0, 3.1, 3.2, head, debug, jruby, jruby-head, truffleruby, truffleruby-head]
|
25
|
+
ruby: [2.7, 3.0, 3.1, 3.2, head, debug, jruby, jruby-head, truffleruby, truffleruby-head]
|
26
26
|
continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }}
|
27
27
|
steps:
|
28
28
|
- uses: actions/checkout@v3
|
data/README.md
CHANGED
@@ -87,7 +87,7 @@ require 'fakeredis/minitest'
|
|
87
87
|
|
88
88
|
## Acknowledgements
|
89
89
|
|
90
|
-
Thanks to [all contributors](https://github.com/guilleiguaran/fakeredis/graphs/contributors)
|
90
|
+
Thanks to [all contributors](https://github.com/guilleiguaran/fakeredis/graphs/contributors).
|
91
91
|
|
92
92
|
## Contributing to FakeRedis
|
93
93
|
|
@@ -74,7 +74,7 @@ module FakeRedis
|
|
74
74
|
def georadiusbymember(*args)
|
75
75
|
args = args.dup
|
76
76
|
raise_argument_error("georadiusbymember") if args.size < 4
|
77
|
-
key, member, radius, unit, *
|
77
|
+
key, member, radius, unit, *_ = args
|
78
78
|
raise_argument_error("georadiusbymember") unless DISTANCE_UNITS.has_key?(unit)
|
79
79
|
radius *= DISTANCE_UNITS[unit]
|
80
80
|
|
data/lib/fakeredis/version.rb
CHANGED
@@ -122,7 +122,7 @@ class Redis
|
|
122
122
|
"OK"
|
123
123
|
end
|
124
124
|
|
125
|
-
def auth(
|
125
|
+
def auth(*args)
|
126
126
|
"OK"
|
127
127
|
end
|
128
128
|
|
@@ -562,11 +562,17 @@ class Redis
|
|
562
562
|
end
|
563
563
|
|
564
564
|
# 0 = false, 1 = true unless an array was passed in
|
565
|
-
|
565
|
+
if Redis.sadd_returns_boolean && !should_return_int
|
566
|
+
return result == 1
|
567
|
+
end
|
566
568
|
|
567
569
|
result
|
568
570
|
end
|
569
571
|
|
572
|
+
def sadd?(key, value)
|
573
|
+
sadd(key, value) == 1
|
574
|
+
end
|
575
|
+
|
570
576
|
def srem(key, value)
|
571
577
|
data_type_check(key, ::Set)
|
572
578
|
raise_argument_error('srem') if Array(value).empty?
|
@@ -775,28 +781,28 @@ class Redis
|
|
775
781
|
def hset(key, *fields)
|
776
782
|
fields = fields.first if fields.size == 1 && fields.first.is_a?(Hash)
|
777
783
|
raise_argument_error('hset') if fields.empty?
|
778
|
-
|
784
|
+
|
779
785
|
is_list_of_arrays = fields.all?{|field| field.instance_of?(Array)}
|
780
|
-
|
786
|
+
|
781
787
|
raise_argument_error('hmset') if fields.size.odd? and !is_list_of_arrays
|
782
788
|
raise_argument_error('hmset') if is_list_of_arrays and !fields.all?{|field| field.length == 2}
|
783
|
-
|
789
|
+
|
784
790
|
data_type_check(key, Hash)
|
785
791
|
insert_count = 0
|
786
792
|
data[key] ||= {}
|
787
|
-
|
793
|
+
|
788
794
|
if fields.is_a?(Hash)
|
789
795
|
insert_count = fields.keys.size - (data[key].keys & fields.keys).size
|
790
|
-
|
796
|
+
|
791
797
|
data[key].merge!(fields)
|
792
798
|
else
|
793
799
|
fields.each_slice(2) do |field|
|
794
800
|
insert_count += 1 if data[key][field[0].to_s].nil?
|
795
|
-
|
801
|
+
|
796
802
|
data[key][field[0].to_s] = field[1].to_s
|
797
803
|
end
|
798
804
|
end
|
799
|
-
|
805
|
+
|
800
806
|
insert_count
|
801
807
|
end
|
802
808
|
|
@@ -1150,12 +1156,12 @@ class Redis
|
|
1150
1156
|
count.nil? ? results.first : results.flatten
|
1151
1157
|
end
|
1152
1158
|
|
1153
|
-
def bzpopmax(*args)
|
1154
|
-
bzpop(:bzpopmax, args)
|
1159
|
+
def bzpopmax(*args, timeout: 0)
|
1160
|
+
bzpop(:bzpopmax, args, timeout)
|
1155
1161
|
end
|
1156
1162
|
|
1157
|
-
def bzpopmin(*args)
|
1158
|
-
bzpop(:bzpopmin, args)
|
1163
|
+
def bzpopmin(*args, timeout: 0)
|
1164
|
+
bzpop(:bzpopmin, args, timeout)
|
1159
1165
|
end
|
1160
1166
|
|
1161
1167
|
def zcard(key)
|
@@ -1594,15 +1600,7 @@ class Redis
|
|
1594
1600
|
end
|
1595
1601
|
end
|
1596
1602
|
|
1597
|
-
def bzpop(command, args)
|
1598
|
-
timeout =
|
1599
|
-
if args.last.is_a?(Hash)
|
1600
|
-
args.pop[:timeout]
|
1601
|
-
elsif args.last.respond_to?(:to_int)
|
1602
|
-
args.pop.to_int
|
1603
|
-
end
|
1604
|
-
|
1605
|
-
timeout ||= 0
|
1603
|
+
def bzpop(command, args, timeout)
|
1606
1604
|
single_pop_command = command.to_s[1..-1]
|
1607
1605
|
keys = args.flatten
|
1608
1606
|
keys.each do |key|
|
data/spec/sets_spec.rb
CHANGED
@@ -7,8 +7,8 @@ module FakeRedis
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it "should add a member to a set" do
|
10
|
-
expect(@client.sadd("key", "value")).to eq(true)
|
11
|
-
expect(@client.sadd("key", "value")).to eq(false)
|
10
|
+
expect(@client.sadd?("key", "value")).to eq(true)
|
11
|
+
expect(@client.sadd?("key", "value")).to eq(false)
|
12
12
|
|
13
13
|
expect(@client.smembers("key")).to eq(["value"])
|
14
14
|
end
|
data/spec/sorted_sets_spec.rb
CHANGED
@@ -120,14 +120,14 @@ module FakeRedis
|
|
120
120
|
it "should pop members with the highest score from first sorted set that is non-empty" do
|
121
121
|
@client.zadd("key1", [1, "val1", 2, "val2"])
|
122
122
|
@client.zadd("key2", [3, "val3"])
|
123
|
-
expect(@client.bzpopmax("nonexistent", "key1", "key2", 0)).to eq(["key1", "val2", 2.0])
|
123
|
+
expect(@client.bzpopmax("nonexistent", "key1", "key2", timeout: 0)).to eq(["key1", "val2", 2.0])
|
124
124
|
expect(@client.bzpopmax("nonexistent")).to eq(nil)
|
125
125
|
end
|
126
126
|
|
127
127
|
it "should pop members with the lowest score from first sorted set that is non-empty" do
|
128
128
|
@client.zadd("key1", [1, "val1", 2, "val2"])
|
129
129
|
@client.zadd("key2", [3, "val3"])
|
130
|
-
expect(@client.bzpopmin("nonexistent", "key1", "key2", 0)).to eq(["key1", "val1", 1.0])
|
130
|
+
expect(@client.bzpopmin("nonexistent", "key1", "key2", timeout: 0)).to eq(["key1", "val1", 1.0])
|
131
131
|
expect(@client.bzpopmin("nonexistent")).to eq(nil)
|
132
132
|
end
|
133
133
|
|
data/spec/spec_helper.rb
CHANGED
@@ -11,6 +11,9 @@ RSpec.configure do |config|
|
|
11
11
|
# Enable memory adapter
|
12
12
|
config.before(:each) { FakeRedis.enable }
|
13
13
|
|
14
|
+
# Set the default behavior for sadd in v5.0
|
15
|
+
config.before(:all) { Redis.sadd_returns_boolean = false }
|
16
|
+
|
14
17
|
config.backtrace_exclusion_patterns = []
|
15
18
|
end
|
16
19
|
|
data/spec/transactions_spec.rb
CHANGED
@@ -94,8 +94,8 @@ module FakeRedis
|
|
94
94
|
@client.sadd('set', 'member1')
|
95
95
|
|
96
96
|
responses = @client.multi do |multi|
|
97
|
-
multi.sadd('set', 'member1')
|
98
|
-
multi.sadd('set', 'member2')
|
97
|
+
multi.sadd?('set', 'member1')
|
98
|
+
multi.sadd?('set', 'member2')
|
99
99
|
end
|
100
100
|
|
101
101
|
expect(responses).to eq([false, true])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fakeredis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guillermo Iguaran
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|