diff --git a/CHANGELOG.md b/CHANGELOG.md index e967847..939d4bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +- support for `ActiveSupport::Cache::MemCacheStore`; - configuration layer `AnyCache.configure`: an ability to choose and configure a necessary cache client without any explicit client object instantiation (client object will be instantiated implicitly); diff --git a/README.md b/README.md index ded9d69..f90d3eb 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ require 'any_cache' - [AnyCache with Redis::Store](#anycache-with-redisstore) - [AnyCache with Dalli::Client](#anycache-with-dalliclient) - [AnyCache with ActiveSupport::Cache::RedisCacheStore](#anycache-with-activesupportcacherediscachestore) - - [AnyCache with ActiveSupport::Cache::MemCacheStore](#anycache-with-activesupportmemcachestore) + - [AnyCache with ActiveSupport::Cache::MemCacheStore](#anycache-with-activesupportcachememcachestore) - [AnyCache with ActiveSupport::Cache::FileStore](#anycache-with-activesupportcachefilestore) - [AnyCache with ActiveSupport::Cache::MemoryStore](#anycache-with-activesupportcachememorystore) - [Many cache storages](#many-cache-storages) @@ -69,8 +69,8 @@ Supported clients: - `Redis` - `Redis::Store` - `Dalli::Client` -- `ActiveSupport::Cache::MemCacheStore` - `ActiveSupport::Cache::RedisCacheStore` +- `ActiveSupport::Cache::MemCacheStore` - `ActiveSupport::Cache::FileStore` - `ActiveSupport::Cache::MemoryStore` @@ -116,7 +116,7 @@ Supported drivers: - `:redis` - [Redis](#anycache-with-redis); - `:redis_tore` - [Redis::Client](#anycache-with-redisstore); -- `:dalli` - [Dalli::Clien](#anycache-with-dalliclient); +- `:dalli` - [Dalli::Client](#anycache-with-dalliclient); - `:as_redis_cache_store` - [ActiveSupport::Cache::RedisCacheStore](#anycache-with-activesupportcacherediscachestore); - `:as_mem_cache_store` - [ActiveSupport::Cache::MemCacheStore](#anycache-with-activesupportcachememcachestore); - `:as_file_store` - [ActiveSupport::Cache::FileStore](#anycache-with-activesupportcachefilestore); @@ -415,16 +415,11 @@ bin/rspec --test-dalli # run specs with Dalli::Client bin/rspec --test-as-file-store # run specs with ActiveSupport::Cache::FileStore bin/rspec --test-as-memory-store # run specs with ActiveSupport::Cache::MemoryStore bin/rspec --test-as-redis-cache-store # run specs with ActiveSupport::Cache::RedisCacheStore +bin/rspec --test-as-mem-cache-store # run specs with ActiveSupport::Cache::MemCacheStore ``` --- -## Roadmap - -- configuration layer with ability to instantiate cache clients implicitly - ---- - ## Contributing - Fork it (https://github.com/0exp/any_cache/fork) diff --git a/any_cache.gemspec b/any_cache.gemspec index 02c8e65..854db6b 100644 --- a/any_cache.gemspec +++ b/any_cache.gemspec @@ -27,12 +27,12 @@ Gem::Specification.new do |spec| `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec|features)/}) } end - spec.add_dependency 'concurrent-ruby', '~> 1.0' - spec.add_development_dependency 'qonfig', '~> 0.6' + spec.add_dependency 'concurrent-ruby', '~> 1.0' + spec.add_dependency 'qonfig', '~> 0.6' spec.add_development_dependency 'coveralls', '~> 0.8' spec.add_development_dependency 'simplecov', '~> 0.16' - spec.add_development_dependency 'armitage-rubocop', '~> 0.6' + spec.add_development_dependency 'armitage-rubocop', '~> 0.7' spec.add_development_dependency 'rspec', '~> 3.8' spec.add_development_dependency 'bundler' diff --git a/bin/rspec b/bin/rspec index a9f55dc..72fa39c 100755 --- a/bin/rspec +++ b/bin/rspec @@ -17,7 +17,7 @@ module AnyCacheSpecRunner dalli: expand_gemfile_path('dalli.gemfile'), active_support: expand_gemfile_path('active_support.gemfile'), active_support_with_redis: expand_gemfile_path('active_support_with_redis.gemfile'), - active_support_with_dalli: expand_gemfile_path('active_support_with_dalli.gemfile'), + active_support_with_dalli: expand_gemfile_path('active_support_with_dalli.gemfile') }.freeze # rubocop:disable Metrics/MethodLength, Metrics/BlockLength diff --git a/lib/any_cache/adapters/active_support_mem_cache_store.rb b/lib/any_cache/adapters/active_support_mem_cache_store.rb index b99ef74..443688a 100644 --- a/lib/any_cache/adapters/active_support_mem_cache_store.rb +++ b/lib/any_cache/adapters/active_support_mem_cache_store.rb @@ -101,7 +101,7 @@ def decrement(key, amount = DEFAULT_INCR_DECR_AMOUNT, **options) if is_initial # NOTE: Dalli::Client can't decrement: # - non-raw values; - # - values lower lower than zero; + # - values lower than zero; # - empty entries; write(key, INITIAL_DECREMNETED_VALUE, expires_in: expires_in) && INITIAL_DECREMNETED_VALUE else diff --git a/lib/any_cache/drivers/active_support_mem_cache_store.rb b/lib/any_cache/drivers/active_support_mem_cache_store.rb index cafc81a..19a6731 100644 --- a/lib/any_cache/drivers/active_support_mem_cache_store.rb +++ b/lib/any_cache/drivers/active_support_mem_cache_store.rb @@ -1,4 +1,4 @@ -# frozen_string_ltieral: true +# frozen_string_literal: true module AnyCache::Drivers::ActiveSupportMemCacheStore class << self @@ -19,9 +19,7 @@ def supported_source?(driver) # @api private # @since 0.2.0 def build(settings) - ::ActiveSupport::Cache::MemCacheStore.new([ - Array(settings.servers), settings.options - ]) + ::ActiveSupport::Cache::MemCacheStore.new([Array(settings.servers), settings.options]) end end end diff --git a/lib/any_cache/drivers/dalli.rb b/lib/any_cache/drivers/dalli.rb index 13669b0..fd98a31 100644 --- a/lib/any_cache/drivers/dalli.rb +++ b/lib/any_cache/drivers/dalli.rb @@ -19,7 +19,7 @@ def supported_source?(driver) # @api private # @sicne 0.2.0 def build(settings) - ::Dalli::Client.new(settings.servers, settings.options) + ::Dalli::Client.new(Array(settings.servers), settings.options) end end end diff --git a/spec/features/increment_spec.rb b/spec/features/increment_spec.rb index ccad4c7..1276fb3 100644 --- a/spec/features/increment_spec.rb +++ b/spec/features/increment_spec.rb @@ -69,7 +69,7 @@ context 'with previously defined permanent entry' do before { cache_store.write(entry[:key], entry[:value]) } - # it_behaves_like 'incrementation' + it_behaves_like 'incrementation' context 'with re-expiration' do specify 'entry gets new expiration time' do diff --git a/spec/support/spec_support/cache/active_support_mem_cache_store.rb b/spec/support/spec_support/cache/active_support_mem_cache_store.rb index a71fc20..5aa2c0f 100644 --- a/spec/support/spec_support/cache/active_support_mem_cache_store.rb +++ b/spec/support/spec_support/cache/active_support_mem_cache_store.rb @@ -5,7 +5,7 @@ class CacheStore < AnyCache configure do |conf| conf.driver = :as_mem_cache_store conf.as_mem_cache_store.servers = '127.0.0.1:11211' - conf.as_mem_cache_store.options = { namespace: 'blastwave' } + conf.as_mem_cache_store.options = { namespace: 'any_cache' } end end diff --git a/spec/support/spec_support/cache/dalli.rb b/spec/support/spec_support/cache/dalli.rb index 4f57063..dd868dd 100644 --- a/spec/support/spec_support/cache/dalli.rb +++ b/spec/support/spec_support/cache/dalli.rb @@ -5,7 +5,7 @@ class CacheStore < AnyCache configure do |conf| conf.driver = :dalli conf.dalli.servers = '127.0.0.1:11211' - conf.dalli.options = { namespace: 'blastwave' } + conf.dalli.options = { namespace: 'any_cache' } end end