redis-prescription 2.5.0 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/redis_prescription/adapters/redis.rb +15 -17
- data/lib/redis_prescription/adapters/redis_client.rb +17 -19
- data/lib/redis_prescription/adapters/redis_namespace.rb +15 -17
- data/lib/redis_prescription/adapters.rb +3 -3
- data/lib/redis_prescription/version.rb +1 -1
- data/lib/redis_prescription.rb +4 -4
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b40f45880782f9837583276b82f9d8c7469ea9ecb43975c3c0f39ba443ef5ee9
|
4
|
+
data.tar.gz: 4b30c8e0542b78426afb3cc6eedeae0b62f621043f32c39e3d58e438a34f7c59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23541e2d295d44ebb114fe031c84a1219a996c8b7566f6ad1f4b67ccf3b851ee5d5ece5aac8cb12549c6ac292b32b20471f0949f41b9b91014bec945290bd1c0
|
7
|
+
data.tar.gz: ea5b760e8c10d489a566da3a4a9135b2cb0b0e8c02da87c89e9169ee3d92490d87b8eb979393695133d0731b63ed7d048278596af100c703817102a7cb34bcbe
|
@@ -5,25 +5,23 @@ require_relative "../errors"
|
|
5
5
|
class RedisPrescription
|
6
6
|
module Adapters
|
7
7
|
# redis-rb adapter
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
def initialize(redis)
|
14
|
-
@redis = redis
|
15
|
-
end
|
8
|
+
module Redis
|
9
|
+
class << self
|
10
|
+
def adapts?(redis)
|
11
|
+
defined?(::Redis) && redis.is_a?(::Redis)
|
12
|
+
end
|
16
13
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
14
|
+
def eval(redis, script, keys, argv)
|
15
|
+
redis.eval(script, keys, argv)
|
16
|
+
rescue ::Redis::CommandError => e
|
17
|
+
raise CommandError, e.message
|
18
|
+
end
|
22
19
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
def evalsha(redis, digest, keys, argv)
|
21
|
+
redis.evalsha(digest, keys, argv)
|
22
|
+
rescue ::Redis::CommandError => e
|
23
|
+
raise CommandError, e.message
|
24
|
+
end
|
27
25
|
end
|
28
26
|
end
|
29
27
|
end
|
@@ -5,28 +5,26 @@ require_relative "../errors"
|
|
5
5
|
class RedisPrescription
|
6
6
|
module Adapters
|
7
7
|
# redis-client adapter
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
module RedisClient
|
9
|
+
class << self
|
10
|
+
def adapts?(redis)
|
11
|
+
return true if defined?(::RedisClient) && redis.is_a?(::RedisClient)
|
12
|
+
return true if defined?(::RedisClient::Decorator::Client) && redis.is_a?(::RedisClient::Decorator::Client)
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
def initialize(redis)
|
17
|
-
@redis = redis
|
18
|
-
end
|
14
|
+
false
|
15
|
+
end
|
19
16
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
def eval(redis, script, keys, argv)
|
18
|
+
redis.call("EVAL", script, keys.size, *keys, *argv)
|
19
|
+
rescue ::RedisClient::CommandError => e
|
20
|
+
raise CommandError, e.message
|
21
|
+
end
|
25
22
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
23
|
+
def evalsha(redis, digest, keys, argv)
|
24
|
+
redis.call("EVALSHA", digest, keys.size, *keys, *argv)
|
25
|
+
rescue ::RedisClient::CommandError => e
|
26
|
+
raise CommandError, e.message
|
27
|
+
end
|
30
28
|
end
|
31
29
|
end
|
32
30
|
end
|
@@ -5,25 +5,23 @@ require_relative "../errors"
|
|
5
5
|
class RedisPrescription
|
6
6
|
module Adapters
|
7
7
|
# redis-namespace adapter
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
def initialize(redis)
|
14
|
-
@redis = redis
|
15
|
-
end
|
8
|
+
module RedisNamespace
|
9
|
+
class << self
|
10
|
+
def adapts?(redis)
|
11
|
+
defined?(::Redis::Namespace) && redis.is_a?(::Redis::Namespace)
|
12
|
+
end
|
16
13
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
14
|
+
def eval(redis, script, keys, argv)
|
15
|
+
redis.eval(script, keys, argv)
|
16
|
+
rescue ::Redis::CommandError => e
|
17
|
+
raise CommandError, e.message
|
18
|
+
end
|
22
19
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
def evalsha(redis, digest, keys, argv)
|
21
|
+
redis.evalsha(digest, keys, argv)
|
22
|
+
rescue ::Redis::CommandError => e
|
23
|
+
raise CommandError, e.message
|
24
|
+
end
|
27
25
|
end
|
28
26
|
end
|
29
27
|
end
|
@@ -9,9 +9,9 @@ class RedisPrescription
|
|
9
9
|
module Adapters
|
10
10
|
class << self
|
11
11
|
def [](redis)
|
12
|
-
return Adapters::Redis
|
13
|
-
return Adapters::RedisClient
|
14
|
-
return Adapters::RedisNamespace
|
12
|
+
return Adapters::Redis if Adapters::Redis.adapts?(redis)
|
13
|
+
return Adapters::RedisClient if Adapters::RedisClient.adapts?(redis)
|
14
|
+
return Adapters::RedisNamespace if Adapters::RedisNamespace.adapts?(redis)
|
15
15
|
|
16
16
|
raise TypeError, "Unsupported redis client: #{redis.class}"
|
17
17
|
end
|
data/lib/redis_prescription.rb
CHANGED
@@ -46,18 +46,18 @@ class RedisPrescription
|
|
46
46
|
# @raise [ScriptError] if script execution failed
|
47
47
|
# @return depends on the script
|
48
48
|
def call(redis, keys: EMPTY_LIST, argv: EMPTY_LIST)
|
49
|
-
evalsha_with_fallback(Adapters[redis], keys, argv)
|
49
|
+
evalsha_with_fallback(Adapters[redis], redis, keys, argv)
|
50
50
|
rescue CommandError => e
|
51
51
|
raise ScriptError.new(e.message, @source)
|
52
52
|
end
|
53
53
|
|
54
54
|
private
|
55
55
|
|
56
|
-
def evalsha_with_fallback(redis, keys, argv)
|
57
|
-
|
56
|
+
def evalsha_with_fallback(adapter, redis, keys, argv)
|
57
|
+
adapter.evalsha(redis, @digest, keys, argv)
|
58
58
|
rescue CommandError => e
|
59
59
|
raise unless e.message.include?(NOSCRIPT)
|
60
60
|
|
61
|
-
|
61
|
+
adapter.eval(redis, @source, keys, argv)
|
62
62
|
end
|
63
63
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-prescription
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexey Zapparov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
Preloads (and reloads when needed, e.g. when scripts were flushed away)
|
@@ -35,9 +35,9 @@ licenses:
|
|
35
35
|
- MIT
|
36
36
|
metadata:
|
37
37
|
homepage_uri: https://gitlab.com/ixti/redis-prescription
|
38
|
-
source_code_uri: https://gitlab.com/ixti/redis-prescription
|
38
|
+
source_code_uri: https://gitlab.com/ixti/redis-prescription/tree/v2.6.0
|
39
39
|
bug_tracker_uri: https://gitlab.com/ixti/redis-prescription/issues
|
40
|
-
changelog_uri: https://gitlab.com/ixti/redis-prescription/blob/v2.
|
40
|
+
changelog_uri: https://gitlab.com/ixti/redis-prescription/blob/v2.6.0/CHANGES.md
|
41
41
|
rubygems_mfa_required: 'true'
|
42
42
|
post_install_message:
|
43
43
|
rdoc_options: []
|