aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-07-17 14:43:08 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2008-07-17 14:43:08 -0700
commit8f9702db5cdd2afeca267f883980d4dcd4659edc (patch)
tree526b62a0565fbf89decc9148f3e935f313c6dc06 /activesupport/lib
parent636e6b7138864ceb1e309939cd879e710b287f3e (diff)
parent7359597004a63277851acbc87f0267d3d63e17eb (diff)
downloadrails-8f9702db5cdd2afeca267f883980d4dcd4659edc.tar.gz
rails-8f9702db5cdd2afeca267f883980d4dcd4659edc.tar.bz2
rails-8f9702db5cdd2afeca267f883980d4dcd4659edc.zip
Merge branch 'master' of git@github.com:rails/rails
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/cache.rb36
1 files changed, 15 insertions, 21 deletions
diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb
index 3e3dc18263..5a064f8bea 100644
--- a/activesupport/lib/active_support/cache.rb
+++ b/activesupport/lib/active_support/cache.rb
@@ -21,7 +21,7 @@ module ActiveSupport
expanded_cache_key = namespace ? "#{namespace}/" : ""
if ENV["RAILS_CACHE_ID"] || ENV["RAILS_APP_VERSION"]
- expanded_cache_key << "#{ENV["RAILS_CACHE_ID"] || ENV["RAILS_APP_VERSION"]}/"
+ expanded_cache_key << "#{ENV["RAILS_CACHE_ID"] || ENV["RAILS_APP_VERSION"]}/"
end
expanded_cache_key << case
@@ -36,16 +36,15 @@ module ActiveSupport
expanded_cache_key
end
-
class Store
cattr_accessor :logger
- def initialize
+ def threadsafe!
+ extend ThreadSafety
end
- def threadsafe!
- @mutex = Mutex.new
- self.class.send :include, ThreadSafety
+ def silence!
+ @silence = true
self
end
@@ -110,29 +109,24 @@ module ActiveSupport
nil
end
end
-
+
private
def log(operation, key, options)
- logger.debug("Cache #{operation}: #{key}#{options ? " (#{options.inspect})" : ""}") if logger && !@logger_off
+ logger.debug("Cache #{operation}: #{key}#{options ? " (#{options.inspect})" : ""}") if logger && !@silence && !@logger_off
end
end
-
module ThreadSafety #:nodoc:
- def read(key, options = nil) #:nodoc:
- @mutex.synchronize { super }
- end
-
- def write(key, value, options = nil) #:nodoc:
- @mutex.synchronize { super }
- end
-
- def delete(key, options = nil) #:nodoc:
- @mutex.synchronize { super }
+ def self.extended(object) #:nodoc:
+ object.instance_variable_set(:@mutex, Mutex.new)
end
- def delete_matched(matcher, options = nil) #:nodoc:
- @mutex.synchronize { super }
+ %w(read write delete delete_matched exist? increment decrement).each do |method|
+ module_eval <<-EOS, __FILE__, __LINE__
+ def #{method}(*args)
+ @mutex.synchronize { super }
+ end
+ EOS
end
end
end