artirix_cache_service 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/artirix_cache_service/service.rb +1 -0
- data/lib/artirix_cache_service/variables_store_service.rb +13 -2
- data/lib/artirix_cache_service/variables_stores/redis.rb +6 -8
- data/lib/artirix_cache_service/version.rb +1 -1
- data/lib/artirix_cache_service.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a0ea648b7e79651791a637e66ab6ade88778c41
|
4
|
+
data.tar.gz: 20b685ebb5d90b54dd13685bdec71d8309c58419
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd2f62e046b3b8bdc907b143a84a3e278ac5706d8c7bf1d0c18d3f69ad7c90280fee0a22b8df4b2e6d70b2b3b9b253399cd972015f503782297706ebbf57581d
|
7
|
+
data.tar.gz: 3be9197767cef039f12c724b66283061c6296891011141cecb3da061f137ddfc2429febd351ddb6614e4e5b108f5b67d2141353098ef77ccc9d87d27826b6fca
|
data/README.md
CHANGED
@@ -24,6 +24,7 @@ module ArtirixCacheService
|
|
24
24
|
|
25
25
|
delegate :register_variables_store, :variables_store, :reload_variables_store,
|
26
26
|
:redis_options, :redis_options=,
|
27
|
+
:redis_client, :redis_client=,
|
27
28
|
:redis_variable_prefix, :redis_variable_prefix=,
|
28
29
|
:variable_get, :variable_set, :variables,
|
29
30
|
to: :variables_store_service
|
@@ -2,9 +2,18 @@ module ArtirixCacheService
|
|
2
2
|
class VariablesStoreService
|
3
3
|
DEFAULT_PREFIX = 'artirix_cache_service'.freeze
|
4
4
|
|
5
|
-
attr_writer :
|
5
|
+
attr_writer :redis_client
|
6
6
|
attr_writer :redis_variable_prefix
|
7
7
|
|
8
|
+
def redis_client
|
9
|
+
@redis_client ||= ::Redis.new redis_options
|
10
|
+
end
|
11
|
+
|
12
|
+
def redis_options=(options)
|
13
|
+
@redis_client = nil # to restore the client
|
14
|
+
@redis_options = options
|
15
|
+
end
|
16
|
+
|
8
17
|
def redis_options
|
9
18
|
@redis_options ||= {}
|
10
19
|
end
|
@@ -47,7 +56,9 @@ module ArtirixCacheService
|
|
47
56
|
|
48
57
|
def build_redis(force = false)
|
49
58
|
return @variables_store if !force && @variables_store.kind_of?(VariablesStores::Redis)
|
50
|
-
VariablesStores::Redis.new redis_variable_prefix,
|
59
|
+
VariablesStores::Redis.new redis_variable_prefix: redis_variable_prefix,
|
60
|
+
redis_options: redis_options,
|
61
|
+
redis_client: redis_client
|
51
62
|
end
|
52
63
|
end
|
53
64
|
end
|
@@ -5,15 +5,16 @@ module ArtirixCacheService
|
|
5
5
|
EMPTY_STRING = ''.freeze
|
6
6
|
WILDCARD = '*'.freeze
|
7
7
|
|
8
|
-
attr_reader :redis_variable_prefix
|
8
|
+
attr_reader :redis_variable_prefix, :redis_client
|
9
9
|
|
10
10
|
def type
|
11
11
|
:redis
|
12
12
|
end
|
13
13
|
|
14
|
-
def initialize(redis_variable_prefix
|
14
|
+
def initialize(redis_variable_prefix:, redis_client:, redis_options: {})
|
15
15
|
@redis_variable_prefix = redis_variable_prefix
|
16
16
|
@redis_options = redis_options
|
17
|
+
@redis_client = redis_client
|
17
18
|
end
|
18
19
|
|
19
20
|
def variables
|
@@ -23,15 +24,15 @@ module ArtirixCacheService
|
|
23
24
|
private
|
24
25
|
|
25
26
|
def list
|
26
|
-
|
27
|
+
redis_client.keys(complete_key(WILDCARD))
|
27
28
|
end
|
28
29
|
|
29
30
|
def retrieve(key)
|
30
|
-
|
31
|
+
redis_client.get(complete_key(key))
|
31
32
|
end
|
32
33
|
|
33
34
|
def store(key, value)
|
34
|
-
|
35
|
+
redis_client.set(complete_key(key), value)
|
35
36
|
end
|
36
37
|
|
37
38
|
def complete_key(key)
|
@@ -46,9 +47,6 @@ module ArtirixCacheService
|
|
46
47
|
@clean_listed_regex ||= /^#{redis_variable_prefix}_/
|
47
48
|
end
|
48
49
|
|
49
|
-
def redis
|
50
|
-
@redis ||= ::Redis.new @redis_options
|
51
|
-
end
|
52
50
|
end
|
53
51
|
end
|
54
52
|
end
|
@@ -21,6 +21,7 @@ module ArtirixCacheService
|
|
21
21
|
:registered_options?, :registered_options, :options,
|
22
22
|
:variables_store, :register_variables_store, :reload_variables_store,
|
23
23
|
:redis_options, :redis_options=,
|
24
|
+
:redis_client, :redis_client=,
|
24
25
|
:redis_variable_prefix, :redis_variable_prefix=,
|
25
26
|
:variable_set, :variable_get, :variables,
|
26
27
|
to: :service
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: artirix_cache_service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduardo Turiño
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|