Module: BackgroundCache
- Defined in:
- lib/background_cache.rb,
lib/background_cache/client.rb,
lib/background_cache/config.rb,
lib/background_cache/daemon.rb,
lib/background_cache/helper.rb,
lib/background_cache/mem_cache.rb,
lib/background_cache/controller.rb
Defined Under Namespace
Modules: Controller, Helper, Memcache
Classes: AppInstance, Client, Config, Daemon
Class Method Summary
collapse
Class Method Details
.active? ⇒ Boolean
36
37
38
|
# File 'lib/background_cache.rb', line 36
def self.active?
BackgroundCache::Config.current_cache
end
|
.attach! ⇒ Object
40
41
42
43
44
45
46
47
|
# File 'lib/background_cache.rb', line 40
def self.attach!
ActionController::Base.send(:include, BackgroundCache::Controller)
ActionView::Helpers::CacheHelper.send(:include, BackgroundCache::Helper)
::Dalli::Client.send(:include, BackgroundCache::Memcache) if defined?(::Dalli::Client)
::MemCache.send(:include, BackgroundCache::Memcache) if defined?(::MemCache)
::Memcached::Rails.send(:include, BackgroundCache::Memcache) if defined?(::Memcached::Rails)
end
|
.cache!(group = nil, instance = nil) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/background_cache.rb', line 49
def self.cache!(group=nil, instance=nil)
unless instance
instance = self.boot
end
BackgroundCache::Config.load!(group)
caches = BackgroundCache::Config.caches
caches.each do |cache|
next if group && cache[:group] != group
self.manual(cache, instance)
end
end
|
.manual(cache, instance = nil) ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/background_cache.rb', line 61
def self.manual(cache, instance=nil)
ENV['BACKGROUND_CACHE'] = '1'
unless instance
instance = self.boot
end
BackgroundCache::Config.current_cache = cache
url = cache[:path] || instance.url_for(cache[:params].merge(:only_path => true))
puts "(#{cache[:group]}) #{url}"
instance.get(url)
BackgroundCache::Config.current_cache = nil
url
end
|
.match?(fragment = {}) ⇒ Boolean
74
75
76
|
# File 'lib/background_cache.rb', line 74
def self.match?(fragment={})
BackgroundCache::Config.match?(fragment)
end
|