redis-prescription 2.4.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/README.adoc +1 -0
- data/lib/redis/prescription.rb +5 -2
- data/lib/redis_prescription/adapters/redis.rb +15 -26
- data/lib/redis_prescription/adapters/redis_client.rb +20 -31
- data/lib/redis_prescription/adapters/redis_namespace.rb +15 -26
- data/lib/redis_prescription/adapters.rb +3 -3
- data/lib/redis_prescription/version.rb +1 -1
- data/lib/redis_prescription.rb +6 -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
|
data/README.adoc
CHANGED
data/lib/redis/prescription.rb
CHANGED
@@ -3,10 +3,13 @@
|
|
3
3
|
require_relative "../redis_prescription"
|
4
4
|
|
5
5
|
class Redis
|
6
|
-
# @deprecated
|
7
|
-
# @see RedisPrescription
|
6
|
+
# @deprecated Use ::RedisPrescription
|
8
7
|
class Prescription < RedisPrescription
|
9
8
|
class << self
|
9
|
+
# Controls if deprecation warnings should be silenced or not.
|
10
|
+
# Defaults to `false`.
|
11
|
+
#
|
12
|
+
# @return [Boolean]
|
10
13
|
attr_accessor :silence_deprecation_warning
|
11
14
|
end
|
12
15
|
|
@@ -5,34 +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
|
16
|
-
|
17
|
-
def adapter_name
|
18
|
-
"redis"
|
19
|
-
end
|
20
|
-
|
21
|
-
def eval(script, keys, argv)
|
22
|
-
@redis.eval(script, keys, argv)
|
23
|
-
rescue ::Redis::CommandError => e
|
24
|
-
raise CommandError, e.message
|
25
|
-
end
|
8
|
+
module Redis
|
9
|
+
class << self
|
10
|
+
def adapts?(redis)
|
11
|
+
defined?(::Redis) && redis.is_a?(::Redis)
|
12
|
+
end
|
26
13
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
32
19
|
|
33
|
-
|
34
|
-
|
35
|
-
|
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
|
36
25
|
end
|
37
26
|
end
|
38
27
|
end
|
@@ -5,37 +5,26 @@ require_relative "../errors"
|
|
5
5
|
class RedisPrescription
|
6
6
|
module Adapters
|
7
7
|
# redis-client adapter
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
def evalsha(digest, keys, argv)
|
31
|
-
@redis.call("EVALSHA", digest, keys.size, *keys, *argv)
|
32
|
-
rescue ::RedisClient::CommandError => e
|
33
|
-
raise CommandError, e.message
|
34
|
-
end
|
35
|
-
|
36
|
-
def purge!
|
37
|
-
@redis.call("SCRIPT", "FLUSH")
|
38
|
-
@redis.call("FLUSHDB")
|
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)
|
13
|
+
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
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
|
22
|
+
|
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
|
39
28
|
end
|
40
29
|
end
|
41
30
|
end
|
@@ -5,34 +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
|
16
|
-
|
17
|
-
def adapter_name
|
18
|
-
"redis-namespace"
|
19
|
-
end
|
20
|
-
|
21
|
-
def eval(script, keys, argv)
|
22
|
-
@redis.eval(script, keys, argv)
|
23
|
-
rescue ::Redis::CommandError => e
|
24
|
-
raise CommandError, e.message
|
25
|
-
end
|
8
|
+
module RedisNamespace
|
9
|
+
class << self
|
10
|
+
def adapts?(redis)
|
11
|
+
defined?(::Redis::Namespace) && redis.is_a?(::Redis::Namespace)
|
12
|
+
end
|
26
13
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
32
19
|
|
33
|
-
|
34
|
-
|
35
|
-
|
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
|
36
25
|
end
|
37
26
|
end
|
38
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
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "digest/sha1"
|
4
|
+
|
3
5
|
require_relative "./redis_prescription/adapters"
|
4
6
|
require_relative "./redis_prescription/errors"
|
5
7
|
require_relative "./redis_prescription/version"
|
@@ -44,18 +46,18 @@ class RedisPrescription
|
|
44
46
|
# @raise [ScriptError] if script execution failed
|
45
47
|
# @return depends on the script
|
46
48
|
def call(redis, keys: EMPTY_LIST, argv: EMPTY_LIST)
|
47
|
-
evalsha_with_fallback(Adapters[redis], keys, argv)
|
49
|
+
evalsha_with_fallback(Adapters[redis], redis, keys, argv)
|
48
50
|
rescue CommandError => e
|
49
51
|
raise ScriptError.new(e.message, @source)
|
50
52
|
end
|
51
53
|
|
52
54
|
private
|
53
55
|
|
54
|
-
def evalsha_with_fallback(redis, keys, argv)
|
55
|
-
|
56
|
+
def evalsha_with_fallback(adapter, redis, keys, argv)
|
57
|
+
adapter.evalsha(redis, @digest, keys, argv)
|
56
58
|
rescue CommandError => e
|
57
59
|
raise unless e.message.include?(NOSCRIPT)
|
58
60
|
|
59
|
-
|
61
|
+
adapter.eval(redis, @source, keys, argv)
|
60
62
|
end
|
61
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: []
|