redis-prescription 2.1.0 → 2.3.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 +13 -2
- 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/errors.rb +1 -1
- data/lib/redis_prescription/version.rb +1 -1
- data/lib/redis_prescription.rb +1 -9
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd1b8f036fcc8230f39b8df81688c9026fd2e65d3e5a825d6d1233a9ba7b9093
|
4
|
+
data.tar.gz: f60221b43f1ddbaa96d57212f8a1e849a94daa9c4d018c90aee7e68d6b9c7df4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11d25b6dc569ed64cab7d439b7688102549a20e714c8a6ff2abfe7a2ccdb91a0fce7097089fd08c196b36b53ca7bcaae149edb0fb3272ec210f95efbcc5134e8
|
7
|
+
data.tar.gz: 386d2fbc0b0104e183c3c58ca871dd0120efe313ea7ece14904137c67139d97d82accc8b8537a0a9887e875596b2b08ec128ce52b73aca534387f873e73e4db9
|
data/README.adoc
CHANGED
@@ -31,20 +31,30 @@ script.call(redis, keys: [:xxx]) # => 123
|
|
31
31
|
----
|
32
32
|
|
33
33
|
|
34
|
-
==
|
34
|
+
== Compatibility
|
35
35
|
|
36
36
|
This library aims to support and is tested against:
|
37
37
|
|
38
38
|
* https://www.ruby-lang.org[Ruby]
|
39
|
+
** MRI 2.7.x
|
39
40
|
** MRI 3.0.x
|
40
41
|
** MRI 3.1.x
|
42
|
+
** MRI 3.2.x
|
41
43
|
* https://redis.io[Redis Server]
|
42
44
|
** 6.2.x
|
43
45
|
** 7.0.x
|
44
46
|
* https://github.com/redis/redis-rb[redis-rb]
|
47
|
+
** 4.1.x
|
48
|
+
** 4.2.x
|
49
|
+
** 4.3.x
|
50
|
+
** 4.4.x
|
51
|
+
** 4.5.x
|
52
|
+
** 4.6.x
|
45
53
|
** 4.7.x
|
46
54
|
** 4.8.x
|
47
55
|
** 5.0.x
|
56
|
+
* https://github.com/resque/redis-namespace[redis-namespace]
|
57
|
+
** 1.10.x
|
48
58
|
* https://github.com/redis-rb/redis-client[redis-client]
|
49
59
|
** 0.12.x
|
50
60
|
** 0.13.x
|
@@ -63,7 +73,8 @@ patches in a timely fashion. If critical issues for a particular implementation
|
|
63
73
|
exist at the time of a major release, support for that Ruby version may be
|
64
74
|
dropped.
|
65
75
|
|
66
|
-
|
76
|
+
The same applies to *Redis Server*, *redis-rb*, *redis-namespace*,
|
77
|
+
and *redis-client* support.
|
67
78
|
|
68
79
|
|
69
80
|
== 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,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.3.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-07 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)
|
@@ -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.3.0/CHANGES.md
|
39
40
|
rubygems_mfa_required: 'true'
|
40
41
|
post_install_message:
|
41
42
|
rdoc_options: []
|
@@ -45,7 +46,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
45
46
|
requirements:
|
46
47
|
- - ">="
|
47
48
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
49
|
+
version: '2.7'
|
49
50
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
51
|
requirements:
|
51
52
|
- - ">="
|