Module: MatrixSdk::Util::Tinycache

Included in:
Room, AccountDataCache, StateEventCache
Defined in:
lib/matrix_sdk/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

.adapterObject



13
14
15
# File 'lib/matrix_sdk/util/tinycache.rb', line 13

def self.adapter
  @adapter ||= TinycacheAdapter
end

.adapter=(adapter) ⇒ Object



17
18
19
# File 'lib/matrix_sdk/util/tinycache.rb', line 17

def self.adapter=(adapter)
  @adapter = adapter
end

.extended(base) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/matrix_sdk/util/tinycache.rb', line 21

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, **opts) ⇒ Object



29
30
31
# File 'lib/matrix_sdk/util/tinycache.rb', line 29

def cached(*methods, **opts)
  methods.each { |method| build_cache_methods(method, **opts) }
end

#tinycache_adapter_configObject



42
43
44
# File 'lib/matrix_sdk/util/tinycache.rb', line 42

def tinycache_adapter_config
  @tinycache_adapter_config ||= {}
end