diff options
author | Brian Durand <brian@embellishedvisions.com> | 2011-12-12 13:40:29 -0600 |
---|---|---|
committer | Brian Durand <brian@embellishedvisions.com> | 2011-12-12 13:40:29 -0600 |
commit | 04d5eae4e835ead8ef785de4eb442893426f4b29 (patch) | |
tree | 3ce45567f9f9a64d88278f58e0907efbb558a5db /activesupport/lib/active_support/cache | |
parent | 2fdc3ab0f10c6614f37621847ff92e8e17283df5 (diff) | |
download | rails-04d5eae4e835ead8ef785de4eb442893426f4b29.tar.gz rails-04d5eae4e835ead8ef785de4eb442893426f4b29.tar.bz2 rails-04d5eae4e835ead8ef785de4eb442893426f4b29.zip |
Add ActiveSupport::Cache::NullStore to expose caching interface without actually caching for development and test environments.
Diffstat (limited to 'activesupport/lib/active_support/cache')
-rw-r--r-- | activesupport/lib/active_support/cache/null_store.rb | 44 |
1 files changed, 44 insertions, 0 deletions
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 |