Module: Card::Set::All::Cache

Extended by:
Card::Set
Defined in:
tmpsets/set/mod003-core/all/cache.rb

Overview

Set: All cards (Cache)

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Methods included from I18nScope

#mod_name, #scope

Methods included from Loader

#clean_empty_module_from_hash, #clean_empty_modules, #extended, #process_base_modules, #register_set

Methods included from Helpers

#abstract_set?, #all_set?, #num_set_parts, #shortname, #underscore

Methods included from Card::Set::AdvancedApi

#attachment, #ensure_set, #stage_method

Methods included from Format

#before, #format, layout_method_name, #view, view_method_name, view_setting_method_name, wrapper_method_name

Methods included from Inheritance

#include_set, #include_set_formats

Methods included from Basket

#abstract_basket, #add_to_basket, #basket, #unshift_basket

Methods included from Trait

#card_accessor, #card_reader, #card_writer, #require_field

Methods included from Event::Api

#event

Class Method Details

.source_locationObject



7
# File 'tmpsets/set/mod003-core/all/cache.rb', line 7

def self.source_location; "/Users/ethan/dev/decko/gem/card/mod/core/set/all/cache.rb"; end

Instance Method Details

#append_missing_view_cache_keysObject



84
85
86
87
88
# File 'tmpsets/set/mod003-core/all/cache.rb', line 84

def append_missing_view_cache_keys
  return unless Card.cache.hard
  @view_cache_keys +=
      (Card.cache.hard.read_attribute(key, :view_cache_keys) || [])
end

#cache_class_from_type(cache_type) ⇒ Object



67
68
69
# File 'tmpsets/set/mod003-core/all/cache.rb', line 67

def cache_class_from_type cache_type
  cache_type ? Card.cache.send(cache_type) : Card.cache
end

#expire(cache_type = nil) ⇒ Object



60
61
62
63
64
65
# File 'tmpsets/set/mod003-core/all/cache.rb', line 60

def expire cache_type=nil
  return unless (cache_class = cache_class_from_type cache_type)
  expire_views
  expire_names cache_class
  expire_id cache_class
end

#expire_id(cache) ⇒ Object



118
119
120
121
# File 'tmpsets/set/mod003-core/all/cache.rb', line 118

def expire_id cache
  return unless id.present?
  cache.delete "~#{id}"
end

#expire_name(name_version, cache) ⇒ Object



111
112
113
114
115
116
# File 'tmpsets/set/mod003-core/all/cache.rb', line 111

def expire_name name_version, cache
  return unless name_version.present?
  key_version = name_version.to_name.key
  return unless key_version.present?
  cache.delete key_version
end

#expire_names(cache) ⇒ Object



105
106
107
108
109
# File 'tmpsets/set/mod003-core/all/cache.rb', line 105

def expire_names cache
  [name, name_before_act].each do |name_version|
    expire_name name_version, cache
  end
end

#expire_piecesObject



54
55
56
57
58
# File 'tmpsets/set/mod003-core/all/cache.rb', line 54

def expire_pieces
  name.piece_names.each do |piece|
    Card.expire piece
  end
end

#expire_viewsObject



96
97
98
99
100
101
102
103
# File 'tmpsets/set/mod003-core/all/cache.rb', line 96

def expire_views
  # puts "EXPIRE VIEW CACHE (#{name}): #{view_cache_keys}"
  return unless view_cache_keys.present?
  Array.wrap(view_cache_keys).each do |view_cache_key|
    Card::View.cache.delete view_cache_key
  end
  @view_cache_keys = nil
end

#hard_write_view_cache_keysObject



90
91
92
93
94
# File 'tmpsets/set/mod003-core/all/cache.rb', line 90

def hard_write_view_cache_keys
  # puts "WRITE VIEW CACHE KEYS (#{name}): #{view_cache_keys}"
  return unless Card.cache.hard
  Card.cache.hard.write_attribute key, :view_cache_keys, view_cache_keys
end

#register_view_cache_key(cache_key) ⇒ Object



71
72
73
74
# File 'tmpsets/set/mod003-core/all/cache.rb', line 71

def register_view_cache_key cache_key
  view_cache_keys cache_key
  hard_write_view_cache_keys
end

#view_cache_keys(new_key = nil) ⇒ Object



76
77
78
79
80
81
82
# File 'tmpsets/set/mod003-core/all/cache.rb', line 76

def view_cache_keys new_key=nil
  @view_cache_keys ||= []
  @view_cache_keys << new_key if new_key
  append_missing_view_cache_keys
  @view_cache_keys.uniq!
  @view_cache_keys
end