Skip to content

Commit

Permalink
[mem-cache-store] Minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
0exp committed Sep 1, 2018
1 parent 9af329f commit 82d58ca
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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`

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions any_cache.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion bin/rspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/any_cache/adapters/active_support_mem_cache_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions lib/any_cache/drivers/active_support_mem_cache_store.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_ltieral: true
# frozen_string_literal: true

module AnyCache::Drivers::ActiveSupportMemCacheStore
class << self
Expand All @@ -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
2 changes: 1 addition & 1 deletion lib/any_cache/drivers/dalli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion spec/features/increment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/support/spec_support/cache/dalli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 82d58ca

Please sign in to comment.