Class | ActiveSupport::Cache::MemoryStore |
In: |
vendor/rails/activesupport/lib/active_support/cache/memory_store.rb
|
Parent: | Store |
A cache store implementation which stores everything into memory in the same process. If you‘re running multiple Ruby on Rails server processes (which is the case if you‘re using mongrel_cluster or Phusion Passenger), then this means that your Rails server process instances won‘t be able to share cache data with each other. If your application never performs manual cache item expiry (e.g. when you‘re using generational cache keys), then using MemoryStore is ok. Otherwise, consider carefully whether you should be using this cache store.
MemoryStore is not only able to store strings, but also arbitrary Ruby objects.
MemoryStore is not thread-safe. Use SynchronizedMemoryStore instead if you need thread-safety.
# File vendor/rails/activesupport/lib/active_support/cache/memory_store.rb, line 18 18: def initialize 19: @data = {} 20: end
# File vendor/rails/activesupport/lib/active_support/cache/memory_store.rb, line 47 47: def clear 48: @data.clear 49: end
# File vendor/rails/activesupport/lib/active_support/cache/memory_store.rb, line 32 32: def delete(name, options = nil) 33: super 34: @data.delete(name) 35: end
# File vendor/rails/activesupport/lib/active_support/cache/memory_store.rb, line 37 37: def delete_matched(matcher, options = nil) 38: super 39: @data.delete_if { |k,v| k =~ matcher } 40: end
# File vendor/rails/activesupport/lib/active_support/cache/memory_store.rb, line 42 42: def exist?(name,options = nil) 43: super 44: @data.has_key?(name) 45: end
# File vendor/rails/activesupport/lib/active_support/cache/memory_store.rb, line 22 22: def read(name, options = nil) 23: super 24: @data[name] 25: end