Created
December 30, 2008 00:34
-
-
Save methodmissing/41455 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Index: vendor/plugins/cache_fu/lib/acts_as_cached/config.rb | |
| =================================================================== | |
| --- vendor/plugins/cache_fu/lib/acts_as_cached/config.rb (revision 2337) | |
| +++ vendor/plugins/cache_fu/lib/acts_as_cached/config.rb (working copy) | |
| @@ -42,9 +42,16 @@ | |
| def setup_memcache(config) | |
| config[:namespace] << "-#{RAILS_ENV}" | |
| - | |
| + | |
| + begin | |
| + require 'caffeine' | |
| + Caffeine::MemCache.class_eval{ attr_reader :namespace } | |
| + rescue | |
| + end | |
| + | |
| silence_warnings do | |
| - Object.const_set :CACHE, MemCache.new(config) | |
| + Object.const_set :CACHE, Object.const_defined?( :Caffeine ) ? Caffeine::MemCache.new( { :namespace => config[:namespace] } ) : MemCache.new(config) | |
| + | |
| end | |
| CACHE.servers = Array(config.delete(:servers)) | |
| Index: vendor/plugins/cache_fu/lib/acts_as_cached/cache_methods.rb | |
| =================================================================== | |
| --- vendor/plugins/cache_fu/lib/acts_as_cached/cache_methods.rb (revision 2337) | |
| +++ vendor/plugins/cache_fu/lib/acts_as_cached/cache_methods.rb (working copy) | |
| @@ -26,7 +26,7 @@ | |
| id = args.first | |
| end | |
| - if (item = fetch_cache(id)).nil? | |
| + if (item = fetch_cache(id)).nil? || item == :MemCache_no_such_entry | |
| set_cache(id, block_given? ? yield : fetch_cachable_data(id), options[:ttl]) | |
| else | |
| item | |
| @@ -239,7 +239,7 @@ | |
| set_cache | |
| end | |
| - # Lourens Naud? | |
| + # Lourens Naudé | |
| def expire_cache_with_associations(*associations_to_sweep) | |
| ((cache_options[:include] || []) + associations_to_sweep).flatten.uniq.compact.each do |assoc| | |
| Array(send(assoc)).compact.each { |item| item.expire_cache if item.respond_to?(:expire_cache) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment