cache_failover 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d5991671822e08f31cb2622b1acfc7e0f916e6666f5cbab87021a066ada840f
4
- data.tar.gz: 77e29f1e8151e7ffead1e13edf1d2ab422724f8acfe260dd1fe842cd1a03254e
3
+ metadata.gz: ed9e82f26ea1cb43e4b188cee7620bb345adba1f320144e3eee891c8b6eba03c
4
+ data.tar.gz: 702f7c9c24287051704a9bc56c5a758db81d764cf5a3b26204ae3dc7b3ae529b
5
5
  SHA512:
6
- metadata.gz: d4cb4b6a5a2804d1eb6de0450f03070870d3c56c9fb4cd78be4fed51f32485479762ddba8c03ad3dd6a067fddc703627000b8eb1988c22e2328e5de5ee3bbbd9
7
- data.tar.gz: 55e91982231ace2529ecc8a47e81be6bbec454d2f695142fea8c2984a346be120a1ecbc3a679c63767d51cb205976cdcc13b12a945266c91b36efa996eb29cd1
6
+ metadata.gz: 84a2ebf66e5e039fb714bff24879fc52aa63d76aa80434dd69f85fdcb24fbfa4763e32996288f8cc55b95dde9ef1f09693f68acacd2c1f98fe0c3137bb4b6c8d
7
+ data.tar.gz: bb2fadf0c46ecd0a4bcd28b7ffbc7535badc43aac63f23937007136a069256d508745d177113c82102a8da50f2d168cb4de1720b7595b356baa514a9c8de5ee1
@@ -4,3 +4,6 @@
4
4
  # Datasource local storage ignored files
5
5
  /dataSources/
6
6
  /dataSources.local.xml
7
+ .idea
8
+
9
+ /.idea/
@@ -11,6 +11,5 @@
11
11
  </content>
12
12
  <orderEntry type="jdk" jdkName="RVM: ruby-3.3.1 [global]" jdkType="RUBY_SDK" />
13
13
  <orderEntry type="sourceFolder" forTests="false" />
14
- <orderEntry type="library" scope="PROVIDED" name="rake (v13.1.0, RVM: ruby-3.3.1 [global]) [gem]" level="application" />
15
14
  </component>
16
15
  </module>
@@ -1,4 +1,4 @@
1
- # Cache Failover Gem [![Gem Version]]
1
+ # Cache Failover Gem
2
2
 
3
3
  ## Installation
4
4
 
@@ -25,6 +25,10 @@ Configure your cache_store normally, but use `CacheFailover::Store` with one arg
25
25
  ```ruby
26
26
  config.cache_store = CacheFailover::Store.new(
27
27
  [
28
+ {
29
+ store: ActiveSupport::Cache::MemCacheStore.new(CONFIG[:MEMCACHED_SERVERS], {}),
30
+ options: {}
31
+ },
28
32
  {
29
33
  store: ActiveSupport::Cache::RedisCacheStore.new(
30
34
  url: CONFIG[:REDIS_URL],
@@ -43,7 +47,6 @@ config.cache_store = CacheFailover::Store.new(
43
47
  ```
44
48
 
45
49
  ## WIP
46
- - Dalli/Memcached support
47
50
  - Memory Cache Support
48
51
  - File Cache support
49
52
  - More options
Binary file
@@ -9,7 +9,7 @@ Gem::Specification.new do |gem|
9
9
  gem.authors = ["chronicaust"]
10
10
  gem.email = ["jamiep@supportabilit.com"]
11
11
  gem.summary = %q{ Failover Handling Cache Store for Rails w/ Brotli compression support. (Redis[Hiredis]/Memcached[Dalli]/SolidCache[MySQL/PG]) }
12
- gem.description = %q{ This gem enabled automatic failover to a secondary caching method when the primary fails. }
12
+ gem.description = %q{ This gem enables automatic failover to a secondary caching method when the primary fails. }
13
13
  gem.homepage = "https://github.com/chronicaust/cache_failover"
14
14
  gem.files = `git ls-files`.split("\n")
15
15
  gem.test_files = gem.files.grep(%r{^(spec)/})
@@ -148,9 +148,7 @@ module CacheFailover
148
148
  true
149
149
  end
150
150
 
151
- REDIS ||=
152
-
153
- private
151
+ private
154
152
 
155
153
  def redis_cnxn(init_options)
156
154
  @redis_cache_client ||=
@@ -163,6 +161,15 @@ module CacheFailover
163
161
  ).new_pool
164
162
  end
165
163
 
164
+ def dalli_cnxn(init_options)
165
+ @dalli_cache_client ||=
166
+ Dalli::Client.new(
167
+ CONFIG[:MEMCACHED_SERVERS],
168
+ failover: init_options[:failover] || true,
169
+ expires_in: init_options[:expires_in] || 300
170
+ )
171
+ end
172
+
166
173
  def cache_db_cnxn(init_options)
167
174
  @db_cache_client ||=
168
175
  ActiveRecord::Base.
@@ -178,6 +185,10 @@ module CacheFailover
178
185
  when 'ActiveSupport::Cache::RedisCacheStore'
179
186
  (redis_cnxn(init_options).call('ping') == 'PONG' rescue false)
180
187
  when 'ActiveSupport::Cache::MemCacheStore'
188
+ dalli_cnxn(init_options).alive!
189
+ dalli_cnxn(init_options).delete('cache_test')
190
+ dalli_cnxn(init_options).add('cache_test', 'success')
191
+ dalli_cnxn(init_options).get('cache_test') == 'success'
181
192
  when 'SolidCache::Store'
182
193
  cache_db_cnxn(init_options).with_connection { ActiveRecord::Base.connection.select_value('SELECT 1=1') == 1 }
183
194
  when 'ActiveSupport::Cache::MemoryStore'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CacheFailover
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cache_failover
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - chronicaust
@@ -206,7 +206,7 @@ dependencies:
206
206
  - - ">="
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
- description: " This gem enabled automatic failover to a secondary caching method when
209
+ description: " This gem enables automatic failover to a secondary caching method when
210
210
  the primary fails. "
211
211
  email:
212
212
  - jamiep@supportabilit.com
@@ -214,13 +214,14 @@ executables: []
214
214
  extensions: []
215
215
  extra_rdoc_files: []
216
216
  files:
217
- - ".idea/.gitignore"
217
+ - ".gitignore"
218
218
  - ".idea/CacheFailover.iml"
219
219
  - ".idea/modules.xml"
220
220
  - ".idea/vcs.xml"
221
+ - README.md
221
222
  - Rakefile
223
+ - cache_failover-0.1.0.gem
222
224
  - cache_failover.gemspec
223
- - lib/README.md
224
225
  - lib/cache_failover.rb
225
226
  - lib/cache_failover/store.rb
226
227
  - lib/cache_failover/version.rb