kredis 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of kredis might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/kredis/migration.rb +9 -3
- data/lib/kredis/types/counter.rb +6 -6
- data/lib/kredis/types/list.rb +7 -7
- data/lib/kredis/types/proxy.rb +13 -7
- data/lib/kredis/types/proxying.rb +2 -2
- data/lib/kredis/types/set.rb +7 -7
- data/lib/kredis/types/unique_list.rb +8 -8
- data/lib/kredis/version.rb +1 -1
- data/lib/kredis.rb +1 -0
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e96a50da4e56bf4088baa6bb6cb7583820ca235a52139b4aa9144b9f9d8585b
|
4
|
+
data.tar.gz: f975deffae4581e3a5d8c208ac2c1bed13686b7d4c1c367289b3f8e5f803b235
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffc338f0f5f0d975c85d5b207c0ace88bd96d7f5047bd0bcd5ad7b600b1e0165df30d6c8af3ef6f51f89b97ea0bf696a2a440b337921076f5676d5562323761e
|
7
|
+
data.tar.gz: de2eb9f5e51df31f9765b2dc5dec59105dc61019818aacacaecc6f1df9a0e99547c5d684baae17f14eeaee1acb64c12a9fb0de919741bffde71e3b55746218f4
|
data/lib/kredis/migration.rb
CHANGED
@@ -30,9 +30,15 @@ class Kredis::Migration
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
def delete_all(
|
34
|
-
|
35
|
-
|
33
|
+
def delete_all(*key_patterns)
|
34
|
+
log_migration "DELETE ALL #{key_patterns.inspect}" do
|
35
|
+
if key_patterns.length > 1
|
36
|
+
@redis.del *key_patterns
|
37
|
+
else
|
38
|
+
each_key_batch_matching(key_patterns.first) do |keys, pipeline|
|
39
|
+
pipeline.del *keys
|
40
|
+
end
|
41
|
+
end
|
36
42
|
end
|
37
43
|
end
|
38
44
|
|
data/lib/kredis/types/counter.rb
CHANGED
@@ -4,16 +4,16 @@ class Kredis::Types::Counter < Kredis::Types::Proxying
|
|
4
4
|
attr_accessor :expires_in
|
5
5
|
|
6
6
|
def increment(by: 1)
|
7
|
-
multi do
|
8
|
-
|
9
|
-
|
7
|
+
multi do
|
8
|
+
set 0, ex: expires_in, nx: true
|
9
|
+
incrby by
|
10
10
|
end[-1]
|
11
11
|
end
|
12
12
|
|
13
13
|
def decrement(by: 1)
|
14
|
-
multi do
|
15
|
-
|
16
|
-
|
14
|
+
multi do
|
15
|
+
set 0, ex: expires_in, nx: true
|
16
|
+
decrby by
|
17
17
|
end[-1]
|
18
18
|
end
|
19
19
|
|
data/lib/kredis/types/list.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class Kredis::Types::List < Kredis::Types::Proxying
|
2
|
-
proxying :lrange, :lrem, :lpush, :rpush, :exists?, :del
|
2
|
+
proxying :lrange, :lrem, :lpush, :ltrim, :rpush, :exists?, :del
|
3
3
|
|
4
4
|
attr_accessor :typed
|
5
5
|
|
@@ -8,16 +8,16 @@ class Kredis::Types::List < Kredis::Types::Proxying
|
|
8
8
|
end
|
9
9
|
alias to_a elements
|
10
10
|
|
11
|
-
def remove(*elements
|
12
|
-
types_to_strings(elements, typed).each { |element|
|
11
|
+
def remove(*elements)
|
12
|
+
types_to_strings(elements, typed).each { |element| lrem 0, element }
|
13
13
|
end
|
14
14
|
|
15
|
-
def prepend(*elements
|
16
|
-
|
15
|
+
def prepend(*elements)
|
16
|
+
lpush types_to_strings(elements, typed) if elements.flatten.any?
|
17
17
|
end
|
18
18
|
|
19
|
-
def append(*elements
|
20
|
-
|
19
|
+
def append(*elements)
|
20
|
+
rpush types_to_strings(elements, typed) if elements.flatten.any?
|
21
21
|
end
|
22
22
|
alias << append
|
23
23
|
|
data/lib/kredis/types/proxy.rb
CHANGED
@@ -2,19 +2,21 @@ class Kredis::Types::Proxy
|
|
2
2
|
require_relative "proxy/failsafe"
|
3
3
|
include Failsafe
|
4
4
|
|
5
|
-
attr_accessor :
|
5
|
+
attr_accessor :key
|
6
|
+
|
7
|
+
thread_mattr_accessor :pipeline
|
6
8
|
|
7
9
|
def initialize(redis, key, **options)
|
8
10
|
@redis, @key = redis, key
|
9
11
|
options.each { |key, value| send("#{key}=", value) }
|
10
12
|
end
|
11
13
|
|
12
|
-
def multi(&block)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
def multi(*args, **kwargs, &block)
|
15
|
+
redis.multi(*args, **kwargs) do |pipeline|
|
16
|
+
self.pipeline = pipeline
|
17
|
+
block.call
|
18
|
+
ensure
|
19
|
+
self.pipeline = nil
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
@@ -27,6 +29,10 @@ class Kredis::Types::Proxy
|
|
27
29
|
end
|
28
30
|
|
29
31
|
private
|
32
|
+
def redis
|
33
|
+
pipeline || @redis
|
34
|
+
end
|
35
|
+
|
30
36
|
def log_message(method, *args, **kwargs)
|
31
37
|
args = args.flatten.reject(&:blank?).presence
|
32
38
|
kwargs = kwargs.reject { |_k, v| v.blank? }.presence
|
@@ -1,14 +1,14 @@
|
|
1
1
|
require "active_support/core_ext/module/delegation"
|
2
2
|
|
3
3
|
class Kredis::Types::Proxying
|
4
|
-
attr_accessor :proxy, :
|
4
|
+
attr_accessor :proxy, :key
|
5
5
|
|
6
6
|
def self.proxying(*commands)
|
7
7
|
delegate *commands, to: :proxy
|
8
8
|
end
|
9
9
|
|
10
10
|
def initialize(redis, key, **options)
|
11
|
-
@
|
11
|
+
@key = key
|
12
12
|
@proxy = Kredis::Types::Proxy.new(redis, key)
|
13
13
|
options.each { |key, value| send("#{key}=", value) }
|
14
14
|
end
|
data/lib/kredis/types/set.rb
CHANGED
@@ -8,19 +8,19 @@ class Kredis::Types::Set < Kredis::Types::Proxying
|
|
8
8
|
end
|
9
9
|
alias to_a members
|
10
10
|
|
11
|
-
def add(*members
|
12
|
-
|
11
|
+
def add(*members)
|
12
|
+
sadd types_to_strings(members, typed) if members.flatten.any?
|
13
13
|
end
|
14
14
|
alias << add
|
15
15
|
|
16
|
-
def remove(*members
|
17
|
-
|
16
|
+
def remove(*members)
|
17
|
+
srem types_to_strings(members, typed) if members.flatten.any?
|
18
18
|
end
|
19
19
|
|
20
20
|
def replace(*members)
|
21
|
-
multi do
|
22
|
-
|
23
|
-
add members
|
21
|
+
multi do
|
22
|
+
del
|
23
|
+
add members
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -8,10 +8,10 @@ class Kredis::Types::UniqueList < Kredis::Types::List
|
|
8
8
|
elements = Array(elements).uniq
|
9
9
|
return if elements.empty?
|
10
10
|
|
11
|
-
multi do
|
12
|
-
remove elements
|
13
|
-
super
|
14
|
-
|
11
|
+
multi do
|
12
|
+
remove elements
|
13
|
+
super
|
14
|
+
ltrim 0, (limit - 1) if limit
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -19,10 +19,10 @@ class Kredis::Types::UniqueList < Kredis::Types::List
|
|
19
19
|
elements = Array(elements).uniq
|
20
20
|
return if elements.empty?
|
21
21
|
|
22
|
-
multi do
|
23
|
-
remove elements
|
24
|
-
super
|
25
|
-
|
22
|
+
multi do
|
23
|
+
remove elements
|
24
|
+
super
|
25
|
+
ltrim -limit, -1 if limit
|
26
26
|
end
|
27
27
|
end
|
28
28
|
alias << append
|
data/lib/kredis/version.rb
CHANGED
data/lib/kredis.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kredis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kasper Timm Hansen
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-09-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -29,16 +29,22 @@ dependencies:
|
|
29
29
|
name: redis
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - "
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '4.2'
|
35
|
+
- - "<"
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '6'
|
35
38
|
type: :runtime
|
36
39
|
prerelease: false
|
37
40
|
version_requirements: !ruby/object:Gem::Requirement
|
38
41
|
requirements:
|
39
|
-
- - "
|
42
|
+
- - ">="
|
40
43
|
- !ruby/object:Gem::Version
|
41
44
|
version: '4.2'
|
45
|
+
- - "<"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '6'
|
42
48
|
- !ruby/object:Gem::Dependency
|
43
49
|
name: rails
|
44
50
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
115
|
- !ruby/object:Gem::Version
|
110
116
|
version: '0'
|
111
117
|
requirements: []
|
112
|
-
rubygems_version: 3.
|
118
|
+
rubygems_version: 3.3.20
|
113
119
|
signing_key:
|
114
120
|
specification_version: 4
|
115
121
|
summary: Higher-level data structures built on Redis.
|