Module: ActiveMatrix::Util::Tinycache
- Included in:
- Room, AccountDataCache, StateEventCache
- Defined in:
- lib/active_matrix/util/tinycache.rb
Defined Under Namespace
Modules: InstanceMethods
Constant Summary collapse
- CACHE_LEVELS =
{ none: 0, some: 1, all: 2 }.freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.adapter ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/active_matrix/util/tinycache.rb', line 13 def self.adapter @adapter ||= if defined?(::Rails) && ::Rails.respond_to?(:cache) require 'active_matrix/util/rails_cache_adapter' RailsCacheAdapter else TinycacheAdapter end end |
.adapter=(adapter) ⇒ Object
22 23 24 |
# File 'lib/active_matrix/util/tinycache.rb', line 22 def self.adapter=(adapter) @adapter = adapter end |
.extended(base) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/active_matrix/util/tinycache.rb', line 26 def self.extended(base) helper_name = base.send(:cache_helper_module_name) base.send :remove_const, helper_name if base.const_defined?(helper_name) base.prepend base.const_set(helper_name, Module.new) base.include InstanceMethods end |
Instance Method Details
#cached(*methods) ⇒ Object
34 35 36 |
# File 'lib/active_matrix/util/tinycache.rb', line 34 def cached(*methods, **) methods.each { |method| build_cache_methods(method, **) } end |
#tinycache_adapter_config ⇒ Object
47 48 49 |
# File 'lib/active_matrix/util/tinycache.rb', line 47 def tinycache_adapter_config @tinycache_adapter_config ||= {} end |