3
# A cache store implementation which stores everything into memory in the
4
# same process. If you're running multiple Ruby on Rails server processes
5
# (which is the case if you're using mongrel_cluster or Phusion Passenger),
6
# then this means that your Rails server process instances won't be able
7
# to share cache data with each other. If your application never performs
8
# manual cache item expiry (e.g. when you're using generational cache keys),
9
# then using MemoryStore is ok. Otherwise, consider carefully whether you
10
# should be using this cache store.
12
# MemoryStore is not only able to store strings, but also arbitrary Ruby
15
# MemoryStore is not thread-safe. Use SynchronizedMemoryStore instead
16
# if you need thread-safety.
17
class MemoryStore < Store
22
def read(name, options = nil)
27
def write(name, value, options = nil)
29
@data[name] = value.freeze
32
def delete(name, options = nil)
37
def delete_matched(matcher, options = nil)
39
@data.delete_if { |k,v| k =~ matcher }
42
def exist?(name,options = nil)