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 +4 -4
- data/README.adoc +4 -1
- data/lib/redis_prescription/adapters/redis.rb +4 -0
- data/lib/redis_prescription/adapters/redis_client.rb +4 -0
- data/lib/redis_prescription/adapters/redis_namespace.rb +39 -0
- data/lib/redis_prescription/adapters.rb +2 -0
- data/lib/redis_prescription/version.rb +1 -1
- data/lib/redis_prescription.rb +1 -9
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c503c680688ac288e5d3b9e59314c20055c10239b31733de6855f6a78ed90d3e
|
4
|
+
data.tar.gz: f0a2373d51deb922ac02bb8283e05cb583dc3578f95ea8f4923bba2d1a3058e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
68
|
+
The same applies to *Redis Server*, *redis-rb*, *redis-namespace*,
|
69
|
+
and *redis-client* support.
|
67
70
|
|
68
71
|
|
69
72
|
== Similar Projects
|
@@ -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
|
data/lib/redis_prescription.rb
CHANGED
@@ -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
|
-
|
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.
|
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.
|
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: []
|