redis-prescription 2.1.0 → 2.2.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: 617a2c55e0d763f97983c56f3e7c7fbea30b4c999736a0eb8eaa4f38dab3a684
4
- data.tar.gz: 16ab341290e6ee88abe15d0c0ee5523b1aaa1ab7b0228e05c9650ff4b861cf52
3
+ metadata.gz: c503c680688ac288e5d3b9e59314c20055c10239b31733de6855f6a78ed90d3e
4
+ data.tar.gz: f0a2373d51deb922ac02bb8283e05cb583dc3578f95ea8f4923bba2d1a3058e1
5
5
  SHA512:
6
- metadata.gz: 654c70a9fda3e076291c0c5339cde768c430c4d960d434fedf9e3bf7e8aaab5d4ea280a1be3a8d554015b09fd8adec26a4f2349ee169cd43e3139ce2b9b6badd
7
- data.tar.gz: ce8112a9aa153b41e05e4e327dbcb6b6bf62abd120a96dad1eacbf818e747899abd7615bf975484850cad540cd4669764e320ce7a07e07d447a371397fe33c55
6
+ metadata.gz: 516e413b8da8d7dace049f9169c307d3a87b1ee52ecdc759368f3012d2d51e6b44732d38a2980635bc5acb1015436960c48fe17239edd734101feda83d18c503
7
+ data.tar.gz: 2c07386fbc7fb53a0a8093df08a35ed6d366a37084df8823cc49685cf95034e5599f7aeacb2fd502ebef6d4f0654f244988e86bd7bd26bfd30c3f0f7741d079b
data/README.adoc CHANGED
@@ -45,6 +45,8 @@ This library aims to support and is tested against:
45
45
  ** 4.7.x
46
46
  ** 4.8.x
47
47
  ** 5.0.x
48
+ * https://github.com/resque/redis-namespace[redis-namespace]
49
+ ** 1.10.x
48
50
  * https://github.com/redis-rb/redis-client[redis-client]
49
51
  ** 0.12.x
50
52
  ** 0.13.x
@@ -63,7 +65,8 @@ patches in a timely fashion. If critical issues for a particular implementation
63
65
  exist at the time of a major release, support for that Ruby version may be
64
66
  dropped.
65
67
 
66
- Same rules apply to *Redis Server*, *redis-rb*, and *redis-client* support.
68
+ The same applies to *Redis Server*, *redis-rb*, *redis-namespace*,
69
+ and *redis-client* support.
67
70
 
68
71
 
69
72
  == Similar Projects
@@ -14,6 +14,10 @@ class RedisPrescription
14
14
  @redis = redis
15
15
  end
16
16
 
17
+ def adapter_name
18
+ "redis"
19
+ end
20
+
17
21
  def eval(script, keys, argv)
18
22
  @redis.eval(script, keys, argv)
19
23
  rescue ::Redis::CommandError => e
@@ -17,6 +17,10 @@ class RedisPrescription
17
17
  @redis = redis
18
18
  end
19
19
 
20
+ def adapter_name
21
+ "redis-client"
22
+ end
23
+
20
24
  def eval(script, keys, argv)
21
25
  @redis.call("EVAL", script, keys.size, *keys, *argv)
22
26
  rescue ::RedisClient::CommandError => e
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../errors"
4
+
5
+ class RedisPrescription
6
+ module Adapters
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
26
+
27
+ def evalsha(digest, keys, argv)
28
+ @redis.evalsha(digest, keys, argv)
29
+ rescue ::Redis::CommandError => e
30
+ raise CommandError, e.message
31
+ end
32
+
33
+ def purge!
34
+ @redis.redis.script("flush")
35
+ @redis.redis.flushdb
36
+ end
37
+ end
38
+ end
39
+ end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative "./adapters/redis"
4
4
  require_relative "./adapters/redis_client"
5
+ require_relative "./adapters/redis_namespace"
5
6
 
6
7
  class RedisPrescription
7
8
  # @api internal
@@ -10,6 +11,7 @@ class RedisPrescription
10
11
  def [](redis)
11
12
  return Adapters::Redis.new(redis) if Adapters::Redis.adapts?(redis)
12
13
  return Adapters::RedisClient.new(redis) if Adapters::RedisClient.adapts?(redis)
14
+ return Adapters::RedisNamespace.new(redis) if Adapters::RedisNamespace.adapts?(redis)
13
15
 
14
16
  raise TypeError, "Unsupported redis client: #{redis.class}"
15
17
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  class RedisPrescription
4
4
  # Gem version.
5
- VERSION = "2.1.0"
5
+ VERSION = "2.2.0"
6
6
  end
@@ -44,21 +44,13 @@ class RedisPrescription
44
44
  # @raise [ScriptError] if script execution failed
45
45
  # @return depends on the script
46
46
  def call(redis, keys: EMPTY_LIST, argv: EMPTY_LIST)
47
- unpool(redis) { |r| evalsha_with_fallback(r, keys, argv) }
47
+ evalsha_with_fallback(Adapters[redis], keys, argv)
48
48
  rescue CommandError => e
49
49
  raise ScriptError.new(e.message, @source)
50
50
  end
51
51
 
52
52
  private
53
53
 
54
- def unpool(redis)
55
- if redis.respond_to?(:with)
56
- redis.with { |r| yield Adapters[r] }
57
- else
58
- yield Adapters[redis]
59
- end
60
- end
61
-
62
54
  def evalsha_with_fallback(redis, keys, argv)
63
55
  redis.evalsha(@digest, keys, argv)
64
56
  rescue CommandError => e
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-prescription
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Zapparov
@@ -26,6 +26,7 @@ files:
26
26
  - lib/redis_prescription/adapters.rb
27
27
  - lib/redis_prescription/adapters/redis.rb
28
28
  - lib/redis_prescription/adapters/redis_client.rb
29
+ - lib/redis_prescription/adapters/redis_namespace.rb
29
30
  - lib/redis_prescription/errors.rb
30
31
  - lib/redis_prescription/version.rb
31
32
  homepage: https://gitlab.com/ixti/redis-prescription
@@ -35,7 +36,7 @@ metadata:
35
36
  homepage_uri: https://gitlab.com/ixti/redis-prescription
36
37
  source_code_uri: https://gitlab.com/ixti/redis-prescription
37
38
  bug_tracker_uri: https://gitlab.com/ixti/redis-prescription/issues
38
- changelog_uri: https://gitlab.com/ixti/redis-prescription/blob/v2.1.0/CHANGES.md
39
+ changelog_uri: https://gitlab.com/ixti/redis-prescription/blob/v2.2.0/CHANGES.md
39
40
  rubygems_mfa_required: 'true'
40
41
  post_install_message:
41
42
  rdoc_options: []