diff options
author | José Valim <jose.valim@gmail.com> | 2011-12-12 14:03:50 -0800 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-12-12 14:03:50 -0800 |
commit | ffa8bfeed91a10c3566a95d159645fa20f75c429 (patch) | |
tree | 5c7bcee3abd2b895f1550baee8f668489b12ede3 /activesupport/lib | |
parent | fa1d9a884c0d5b70c97442e3360ac98ca5fa4340 (diff) | |
parent | 04d5eae4e835ead8ef785de4eb442893426f4b29 (diff) | |
download | rails-ffa8bfeed91a10c3566a95d159645fa20f75c429.tar.gz rails-ffa8bfeed91a10c3566a95d159645fa20f75c429.tar.bz2 rails-ffa8bfeed91a10c3566a95d159645fa20f75c429.zip |
Merge pull request #3954 from bdurand/null_store_2
Add ActiveSupport::Cache::NullStore for testing and development
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/cache.rb | 1 | ||||
-rw-r--r-- | activesupport/lib/active_support/cache/null_store.rb | 44 |
2 files changed, 45 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index 07f5fcdeb3..9711ed6f73 100644 --- a/activesupport/lib/active_support/cache.rb +++ b/activesupport/lib/active_support/cache.rb @@ -16,6 +16,7 @@ module ActiveSupport autoload :FileStore, 'active_support/cache/file_store' autoload :MemoryStore, 'active_support/cache/memory_store' autoload :MemCacheStore, 'active_support/cache/mem_cache_store' + autoload :NullStore, 'active_support/cache/null_store' # These options mean something to all cache implementations. Individual cache # implementations may support additional options. diff --git a/activesupport/lib/active_support/cache/null_store.rb b/activesupport/lib/active_support/cache/null_store.rb new file mode 100644 index 0000000000..4427eaafcd --- /dev/null +++ b/activesupport/lib/active_support/cache/null_store.rb @@ -0,0 +1,44 @@ +module ActiveSupport + module Cache + # A cache store implementation which doesn't actually store anything. Useful in + # development and test environments where you don't want caching turned on but + # need to go through the caching interface. + # + # This cache does implement the local cache strategy, so values will actually + # be cached inside blocks that utilize this strategy. See + # ActiveSupport::Cache::Strategy::LocalCache for more details. + class NullStore < Store + def initialize(options = nil) + super(options) + extend Strategy::LocalCache + end + + def clear(options = nil) + end + + def cleanup(options = nil) + end + + def increment(name, amount = 1, options = nil) + end + + def decrement(name, amount = 1, options = nil) + end + + def delete_matched(matcher, options = nil) + end + + protected + def read_entry(key, options) # :nodoc: + end + + def write_entry(key, entry, options) # :nodoc: + true + end + + def delete_entry(key, options) # :nodoc: + false + end + end + end +end |