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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 102d72bbeaeed7fb1280168260f9f0f93db29aa4629975fef16738cb34d6a412
4
- data.tar.gz: 8012996f4f92d95d082df58df434844a31e8423d066e71b57adcad6b23917aa3
3
+ metadata.gz: b40f45880782f9837583276b82f9d8c7469ea9ecb43975c3c0f39ba443ef5ee9
4
+ data.tar.gz: 4b30c8e0542b78426afb3cc6eedeae0b62f621043f32c39e3d58e438a34f7c59
5
5
  SHA512:
6
- metadata.gz: 6387dd02ae632d8eb0f7e0dbbf2c769bb0349b390c869f0b0f94bfc35123a825bdb0eb529ec06913ac57d23c8fac0513f993aa01db988dab4b3aea5e97f23e5c
7
- data.tar.gz: cabe06b0ec13367f176ea56071547e9881e5fa764398953417e5e4da9e705109d7136d176e3b964a92530cef1d9c7ca2e75334603b3a45c461fc31c6dc3b7e2a
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
- class Redis
9
- def self.adapts?(redis)
10
- defined?(::Redis) && redis.is_a?(::Redis)
11
- end
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
- def eval(script, keys, argv)
18
- @redis.eval(script, keys, argv)
19
- rescue ::Redis::CommandError => e
20
- raise CommandError, e.message
21
- end
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
- def evalsha(digest, keys, argv)
24
- @redis.evalsha(digest, keys, argv)
25
- rescue ::Redis::CommandError => e
26
- raise CommandError, e.message
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
- class RedisClient
9
- def self.adapts?(redis)
10
- return true if defined?(::RedisClient) && redis.is_a?(::RedisClient)
11
- return true if defined?(::RedisClient::Decorator::Client) && redis.is_a?(::RedisClient::Decorator::Client)
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
- false
14
- end
15
-
16
- def initialize(redis)
17
- @redis = redis
18
- end
14
+ false
15
+ end
19
16
 
20
- def eval(script, keys, argv)
21
- @redis.call("EVAL", script, keys.size, *keys, *argv)
22
- rescue ::RedisClient::CommandError => e
23
- raise CommandError, e.message
24
- end
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
- def evalsha(digest, keys, argv)
27
- @redis.call("EVALSHA", digest, keys.size, *keys, *argv)
28
- rescue ::RedisClient::CommandError => e
29
- raise CommandError, e.message
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
- class RedisNamespace
9
- def self.adapts?(redis)
10
- defined?(::Redis::Namespace) && redis.is_a?(::Redis::Namespace)
11
- end
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
- def eval(script, keys, argv)
18
- @redis.eval(script, keys, argv)
19
- rescue ::Redis::CommandError => e
20
- raise CommandError, e.message
21
- end
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
- def evalsha(digest, keys, argv)
24
- @redis.evalsha(digest, keys, argv)
25
- rescue ::Redis::CommandError => e
26
- raise CommandError, e.message
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.new(redis) if Adapters::Redis.adapts?(redis)
13
- return Adapters::RedisClient.new(redis) if Adapters::RedisClient.adapts?(redis)
14
- return Adapters::RedisNamespace.new(redis) if Adapters::RedisNamespace.adapts?(redis)
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
@@ -2,5 +2,5 @@
2
2
 
3
3
  class RedisPrescription
4
4
  # Gem version.
5
- VERSION = "2.5.0"
5
+ VERSION = "2.6.0"
6
6
  end
@@ -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
- redis.evalsha(@digest, keys, argv)
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
- redis.eval(@source, keys, argv)
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.5.0
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-10 00:00:00.000000000 Z
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.5.0/CHANGES.md
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: []