aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/cache/synchronized_memory_store.rb
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2008-09-10 18:56:03 -0500
committerJoshua Peek <josh@joshpeek.com>2008-09-10 18:56:03 -0500
commit2ba9ca95f99c14cd95e90b7bb172ebb29ab25a72 (patch)
treeac99db08fa71da1052306f034239de62e3709d29 /activesupport/lib/active_support/cache/synchronized_memory_store.rb
parent6ce13429cbc1359d85e1dc99c84561840e89d455 (diff)
downloadrails-2ba9ca95f99c14cd95e90b7bb172ebb29ab25a72.tar.gz
rails-2ba9ca95f99c14cd95e90b7bb172ebb29ab25a72.tar.bz2
rails-2ba9ca95f99c14cd95e90b7bb172ebb29ab25a72.zip
Removed monitor from MemoryStore and created a seperate threadsafe store called SynchronizedMemoryStore
Diffstat (limited to 'activesupport/lib/active_support/cache/synchronized_memory_store.rb')
-rw-r--r--activesupport/lib/active_support/cache/synchronized_memory_store.rb46
1 files changed, 46 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/cache/synchronized_memory_store.rb b/activesupport/lib/active_support/cache/synchronized_memory_store.rb
new file mode 100644
index 0000000000..d2ff28768f
--- /dev/null
+++ b/activesupport/lib/active_support/cache/synchronized_memory_store.rb
@@ -0,0 +1,46 @@
+module ActiveSupport
+ module Cache
+ class SynchronizedMemoryStore < MemoryStore
+ def initialize
+ super
+ @guard = Monitor.new
+ end
+
+ def fetch(key, options = {})
+ @guard.synchronize { super }
+ end
+
+ def read(name, options = nil)
+ @guard.synchronize { super }
+ end
+
+ def write(name, value, options = nil)
+ @guard.synchronize { super }
+ end
+
+ def delete(name, options = nil)
+ @guard.synchronize { super }
+ end
+
+ def delete_matched(matcher, options = nil)
+ @guard.synchronize { super }
+ end
+
+ def exist?(name,options = nil)
+ @guard.synchronize { super }
+ end
+
+ def increment(key, amount = 1)
+ @guard.synchronize { super }
+ end
+
+ def decrement(key, amount = 1)
+ @guard.synchronize { super }
+ end
+
+ def clear
+ @guard.synchronize { super }
+ end
+ end
+ end
+end