background_cache 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,7 @@ $:.unshift lib unless $:.include?(lib)
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "background_cache"
9
- s.version = '0.2.5'
9
+ s.version = '0.2.6'
10
10
  s.platform = Gem::Platform::RUBY
11
11
  s.authors = [ "Winton Welsh" ]
12
12
  s.email = [ "mail@wintoni.us" ]
@@ -11,7 +11,7 @@ module BackgroundCache
11
11
 
12
12
  def read_fragment_with_background_cache(key, options=nil)
13
13
  if BackgroundCache.active? && BackgroundCache.match?(key)
14
- RAILS_DEFAULT_LOGGER.info "Cached fragment busted (read_fragment method): #{key}"
14
+ Rails.logger.info "Cached fragment busted (read_fragment method): #{key}"
15
15
  nil
16
16
  else
17
17
  read_fragment_without_background_cache(key, options)
@@ -35,7 +35,11 @@ module BackgroundCache
35
35
  cache = BackgroundCache::Config.current_cache
36
36
  if cache
37
37
  if cache[:layout] == false
38
- @background_cache_layout = controller.active_layout
38
+ if controller.respond_to?(:active_layout)
39
+ @background_cache_layout = controller.active_layout
40
+ else
41
+ @background_cache_layout = controller.send :_layout
42
+ end
39
43
  controller.class.layout(false)
40
44
  else
41
45
  @background_cache_layout = nil
@@ -3,6 +3,7 @@ module BackgroundCache
3
3
 
4
4
  def self.included(base)
5
5
  base.alias_method_chain :get, :background_cache
6
+ base.alias_method_chain :get_multi, :background_cache
6
7
  end
7
8
 
8
9
  def get_with_background_cache(key, raw=false)
@@ -16,5 +17,17 @@ module BackgroundCache
16
17
  get_without_background_cache(key, raw)
17
18
  end
18
19
  end
20
+
21
+ def get_multi_with_background_cache(key, options={})
22
+ match = (
23
+ BackgroundCache.active? &&
24
+ BackgroundCache.match?(key)
25
+ )
26
+ if match
27
+ nil
28
+ else
29
+ get_multi_without_background_cache(key, options)
30
+ end
31
+ end
19
32
  end
20
33
  end
@@ -37,6 +37,17 @@ module BackgroundCache
37
37
  BackgroundCache::Config.current_cache
38
38
  end
39
39
 
40
+ def self.attach!
41
+ ActionController::Base.send(:include, BackgroundCache::Controller)
42
+ ActionView::Helpers::CacheHelper.send(:include, BackgroundCache::Helper)
43
+
44
+ ::Dalli::Client.send(:include, BackgroundCache::Memcache) if defined?(::Dalli::Client)
45
+ ::MemCache.send(:include, BackgroundCache::Memcache) if defined?(::MemCache)
46
+ ::Memcached::Rails.send(:include, BackgroundCache::Memcache) if defined?(::Memcached::Rails)
47
+
48
+ puts "ATTACH!"
49
+ end
50
+
40
51
  def self.cache!(group=nil, instance=nil)
41
52
  unless instance
42
53
  instance = self.boot
data/rails/init.rb CHANGED
@@ -1,8 +1,3 @@
1
1
  require File.expand_path('../../lib/background_cache.rb', __FILE__)
2
2
 
3
- ActionController::Base.send(:include, BackgroundCache::Controller)
4
- ActionView::Helpers::CacheHelper.send(:include, BackgroundCache::Helper)
5
-
6
- ::Dalli::Client.send(:include, BackgroundCache::Memcache) if defined?(::Dalli::Client)
7
- ::MemCache.send(:include, BackgroundCache::Memcache) if defined?(::MemCache)
8
- ::Memcached::Rails.send(:include, BackgroundCache::Memcache) if defined?(::Memcached::Rails)
3
+ BackgroundCache.attach!
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: background_cache
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 5
10
- version: 0.2.5
9
+ - 6
10
+ version: 0.2.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Winton Welsh
@@ -15,7 +15,8 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-03 00:00:00 Z
18
+ date: 2011-11-07 00:00:00 -08:00
19
+ default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: rails
@@ -137,6 +138,7 @@ files:
137
138
  - spec/fixtures/rails/lib/background_cache_config.rb
138
139
  - spec/spec_helper.rb
139
140
  - tasks/background_cache.rake
141
+ has_rdoc: true
140
142
  homepage: http://github.com/winton/background_cache
141
143
  licenses: []
142
144
 
@@ -166,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
168
  requirements: []
167
169
 
168
170
  rubyforge_project:
169
- rubygems_version: 1.8.10
171
+ rubygems_version: 1.4.2
170
172
  signing_key:
171
173
  specification_version: 3
172
174
  summary: Bust caches before your users do