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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65a29d56ab01795d2127f62bccd84a00f4667dca
4
- data.tar.gz: 5d64879751a1b97e376521f6a7c47bf4edaf6058
3
+ metadata.gz: 5a0ea648b7e79651791a637e66ab6ade88778c41
4
+ data.tar.gz: 20b685ebb5d90b54dd13685bdec71d8309c58419
5
5
  SHA512:
6
- metadata.gz: cbf5d72828d7eb04a0b90d2a6a6930433b55001885a8a8550f3e6e2e47abf9b9b366cb9b7b9c83a64cda748482ccc01ffb00024fcc02440ac84a0c428c67d535
7
- data.tar.gz: bd80228958022cf34da234a228b464d1345cd4b3fa4a2e1894bfd45dfdc759ff028811a8beab95131c5923aaf3472c8f032c37b57786af06a59a817093d00317
6
+ metadata.gz: dd2f62e046b3b8bdc907b143a84a3e278ac5706d8c7bf1d0c18d3f69ad7c90280fee0a22b8df4b2e6d70b2b3b9b253399cd972015f503782297706ebbf57581d
7
+ data.tar.gz: 3be9197767cef039f12c724b66283061c6296891011141cecb3da061f137ddfc2429febd351ddb6614e4e5b108f5b67d2141353098ef77ccc9d87d27826b6fca
data/README.md CHANGED
@@ -346,6 +346,10 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/artiri
346
346
 
347
347
  # CHANGELOG
348
348
 
349
+ ## v0.5.1
350
+
351
+ - `redis_client` can now be injected into the service.
352
+
349
353
  ## v0.5.0
350
354
 
351
355
  - added `.variables`
@@ -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 :redis_options
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, redis_options
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, redis_options = {})
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
- redis.keys(complete_key(WILDCARD))
27
+ redis_client.keys(complete_key(WILDCARD))
27
28
  end
28
29
 
29
30
  def retrieve(key)
30
- redis.get(complete_key(key))
31
+ redis_client.get(complete_key(key))
31
32
  end
32
33
 
33
34
  def store(key, value)
34
- redis.set(complete_key(key), value)
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
@@ -1,3 +1,3 @@
1
1
  module ArtirixCacheService
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.1'
3
3
  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.0
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-05 00:00:00.000000000 Z
11
+ date: 2015-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport