diff options
author | Joshua Peek <josh@joshpeek.com> | 2008-08-18 20:14:56 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-08-18 20:17:08 -0500 |
commit | a4da8175a2c989104de1a38e43d5ddfb0f89b055 (patch) | |
tree | 5446ffe7473aaf8f2275e792a3237df4d011ada6 /activesupport/lib/active_support/cache | |
parent | cd8e653d5b18e6d3c3acc9930832f8e23945e392 (diff) | |
download | rails-a4da8175a2c989104de1a38e43d5ddfb0f89b055.tar.gz rails-a4da8175a2c989104de1a38e43d5ddfb0f89b055.tar.bz2 rails-a4da8175a2c989104de1a38e43d5ddfb0f89b055.zip |
Replace MemoryStore mutex with a monitor to avoid issues with nested calls
Diffstat (limited to 'activesupport/lib/active_support/cache')
-rw-r--r-- | activesupport/lib/active_support/cache/memory_store.rb | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/activesupport/lib/active_support/cache/memory_store.rb b/activesupport/lib/active_support/cache/memory_store.rb index a44f877414..7ac6f35357 100644 --- a/activesupport/lib/active_support/cache/memory_store.rb +++ b/activesupport/lib/active_support/cache/memory_store.rb @@ -3,51 +3,63 @@ module ActiveSupport class MemoryStore < Store def initialize @data = {} - @mutex = Mutex.new + @guard = Monitor.new end def fetch(key, options = {}) - @mutex.synchronize do + @guard.synchronize do super end end def read(name, options = nil) - super - @data[name] + @guard.synchronize do + super + @data[name] + end end def write(name, value, options = nil) - super - @data[name] = value + @guard.synchronize do + super + @data[name] = value + end end def delete(name, options = nil) - @data.delete(name) + @guard.synchronize do + @data.delete(name) + end end def delete_matched(matcher, options = nil) - @data.delete_if { |k,v| k =~ matcher } + @guard.synchronize do + @data.delete_if { |k,v| k =~ matcher } + end end def exist?(name,options = nil) - @data.has_key?(name) + @guard.synchronize do + @data.has_key?(name) + end end def increment(key, amount = 1) - @mutex.synchronize do + @guard.synchronize do super end end def decrement(key, amount = 1) - @mutex.synchronize do + @guard.synchronize do super end end def clear - @data.clear + @guard.synchronize do + @data.clear + end end end end |