lib/interlock/interlock.rb in interlock-1.2 vs lib/interlock/interlock.rb in interlock-1.3
- old
+ new
@@ -24,10 +24,15 @@
# Similarly buried and useful: no whitespace allowed in keys.
ILLEGAL_KEY_CHARACTERS_PATTERN = /\s/
mattr_accessor :local_cache
+
+ # Install the pass-through store. This is used in the console and test
+ # environment. In a server environment, the controller callbacks install
+ # the memory store before each request.
+ @@local_cache = Interlock::PassThroughStore.new
class << self
#
# Extract the dependencies from the rest of the arguments and registers
# them with the appropriate models.
@@ -87,12 +92,12 @@
end
end
end
- def say(key, msg) #:nodoc:
- RAILS_DEFAULT_LOGGER.warn "** fragment #{key.inspect[1..-2]} #{msg}"
+ def say(key, msg, type = "fragment") #:nodoc:
+ RAILS_DEFAULT_LOGGER.warn "** #{type} #{key.inspect[1..-2]} #{msg}"
end
#
# Get the Memcached key for a class's dependency list. We store per-class
# to reduce lock contention.
@@ -126,9 +131,12 @@
#
# Invalidate a particular key.
#
def invalidate(key)
+ # Console and tests do not install the local cache
+ Interlock.local_cache.delete(key) if Interlock.local_cache
+
ActionController::Base.fragment_cache_store.delete key
end
end
end