Module: CacheBack
- Defined in:
- lib/cache_back.rb,
lib/cache_back/cache.rb,
lib/cache_back/read_mixin.rb,
lib/cache_back/dirty_mixin.rb,
lib/cache_back/write_mixin.rb,
lib/cache_back/conditions_parser.rb,
lib/cache_back/configuration_mixin.rb,
lib/cache_back/reload_association_mixin.rb
Defined Under Namespace
Modules: ConfigurationMixin, DirtyMixin, ReadMixin, ReloadAssociationMixin, WriteMixin
Classes: Cache, ConditionsParser
Constant Summary
collapse
- CONFIGURATION =
{:max_collection_size => 100}
Class Method Summary
collapse
Class Method Details
.cache ⇒ Object
14
15
16
|
# File 'lib/cache_back.rb', line 14
def cache
Thread.current["cache_back_cache"] ||= Cache.new
end
|
.setup(options = {}) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/cache_back.rb', line 18
def setup(options = {})
CONFIGURATION[:max_collection_size] = options[:max_collection_size] if options[:max_collection_size]
ActiveRecord::Base.extend(CacheBack::ConfigurationMixin)
ActiveRecord::Associations::BelongsToAssociation.send(:include, CacheBack::ReloadAssociationMixin)
ActiveRecord::Associations::BelongsToPolymorphicAssociation.send(:include, CacheBack::ReloadAssociationMixin)
ActiveRecord::Associations::HasOneThroughAssociation.send(:include, CacheBack::ReloadAssociationMixin)
begin
ApplicationController.after_filter do
CacheBack.cache.reset!
end
rescue NameError => e
end
begin
ActiveSupport::TestCase.class_eval do
setup :clear_cache
def clear_cache
CacheBack.cache.reset!
Rails.cache.clear if Rails.cache.respond_to?(:clear)
end
end
rescue NameError => e
end
end
|