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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 354a94422396fda6136797808b779601e496bd65820569745c5394e6ae3da356
4
- data.tar.gz: 19991740730012d7667f792e9c4324ae115fbe3e616d4295616b579cf2f8b7b5
3
+ metadata.gz: b40f45880782f9837583276b82f9d8c7469ea9ecb43975c3c0f39ba443ef5ee9
4
+ data.tar.gz: 4b30c8e0542b78426afb3cc6eedeae0b62f621043f32c39e3d58e438a34f7c59
5
5
  SHA512:
6
- metadata.gz: 3c10f0ee851f6e1b026d3d64b9903f140093b236e1964155bcef5e7c72417e5b68ae79cfc9b647a03c1ebd425d16772022ad2bb8175292e0a83c5231dd2a54e7
7
- data.tar.gz: a605ed2d14492a8e638c16a38bafab2afc37d5cc731c59df65ed3cae067cfeb75d9848115d434a302d7852df78678faccd5646a82568c91d04d8c7be9c19b533
6
+ metadata.gz: 23541e2d295d44ebb114fe031c84a1219a996c8b7566f6ad1f4b67ccf3b851ee5d5ece5aac8cb12549c6ac292b32b20471f0949f41b9b91014bec945290bd1c0
7
+ data.tar.gz: ea5b760e8c10d489a566da3a4a9135b2cb0b0e8c02da87c89e9169ee3d92490d87b8eb979393695133d0731b63ed7d048278596af100c703817102a7cb34bcbe
data/README.adoc CHANGED
@@ -41,6 +41,7 @@ This library aims to support and is tested against:
41
41
  ** MRI 3.1.x
42
42
  ** MRI 3.2.x
43
43
  * https://redis.io[Redis Server]
44
+ ** 6.0.x
44
45
  ** 6.2.x
45
46
  ** 7.0.x
46
47
  * https://github.com/redis/redis-rb[redis-rb]
@@ -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
- 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
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
- def evalsha(digest, keys, argv)
28
- @redis.evalsha(digest, keys, argv)
29
- rescue ::Redis::CommandError => e
30
- raise CommandError, e.message
31
- 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
32
19
 
33
- def purge!
34
- @redis.script("flush")
35
- @redis.flushdb
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
- 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)
12
-
13
- false
14
- end
15
-
16
- def initialize(redis)
17
- @redis = redis
18
- end
19
-
20
- def adapter_name
21
- "redis-client"
22
- end
23
-
24
- def eval(script, keys, argv)
25
- @redis.call("EVAL", script, keys.size, *keys, *argv)
26
- rescue ::RedisClient::CommandError => e
27
- raise CommandError, e.message
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
- 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
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
- def evalsha(digest, keys, argv)
28
- @redis.evalsha(digest, keys, argv)
29
- rescue ::Redis::CommandError => e
30
- raise CommandError, e.message
31
- 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
32
19
 
33
- def purge!
34
- @redis.redis.script("flush")
35
- @redis.redis.flushdb
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.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.4.0"
5
+ VERSION = "2.6.0"
6
6
  end
@@ -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
- redis.evalsha(@digest, keys, argv)
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
- redis.eval(@source, keys, argv)
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.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-07 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.4.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: []