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

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

Overview

Set: All cards (Cache)

Defined Under Namespace

Modules: ClassMethods

Constant Summary

Constants included from Helpers

Helpers::SET_PATTERN_TEST_REGEXP

Constants included from Event::Api

Event::Api::OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Card::Set

reset_modules

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

#method_missing, #num_set_parts, #pattern_code, #respond_to_missing?, #set_name_parts, #shortname, #underscore

Methods included from Card::Set::AdvancedApi

#attachment, #define_set_from_error, #ensure_set, #setting_opts, #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 'card/tmpsets/set/mod002-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

#cache_class_from_type(cache_type) ⇒ Object



62
63
64
# File 'card/tmpsets/set/mod002-core/all/cache.rb', line 62

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

#ensure_view_cache_key(cache_key) ⇒ Object



74
75
76
77
78
79
# File 'card/tmpsets/set/mod002-core/all/cache.rb', line 74

def ensure_view_cache_key cache_key
  return if view_cache_keys.include? cache_key

  @view_cache_keys << cache_key
  hard_write_view_cache_keys
end

#expire(cache_type = nil) ⇒ Object



55
56
57
58
59
60
# File 'card/tmpsets/set/mod002-core/all/cache.rb', line 55

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



113
114
115
116
# File 'card/tmpsets/set/mod002-core/all/cache.rb', line 113

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

#expire_name(name_version, cache) ⇒ Object



106
107
108
109
110
111
# File 'card/tmpsets/set/mod002-core/all/cache.rb', line 106

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



100
101
102
103
104
# File 'card/tmpsets/set/mod002-core/all/cache.rb', line 100

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

#expire_piecesObject



49
50
51
52
53
# File 'card/tmpsets/set/mod002-core/all/cache.rb', line 49

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

#expire_viewsObject



90
91
92
93
94
95
96
97
98
# File 'card/tmpsets/set/mod002-core/all/cache.rb', line 90

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 = []
  hard_write_view_cache_keys
end

#hard_read_view_cache_keysObject



81
82
83
# File 'card/tmpsets/set/mod002-core/all/cache.rb', line 81

def hard_read_view_cache_keys
  Card.cache.hard&.read_attribute key, :view_cache_keys
end

#hard_write_view_cache_keysObject



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

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

#update_soft_cacheObject



45
46
47
# File 'card/tmpsets/set/mod002-core/all/cache.rb', line 45

def update_soft_cache
  Card.write_to_soft_cache self
end

#view_cache_clean?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'card/tmpsets/set/mod002-core/all/cache.rb', line 66

def view_cache_clean?
  !db_content_changed?
end

#view_cache_keysObject



70
71
72
# File 'card/tmpsets/set/mod002-core/all/cache.rb', line 70

def view_cache_keys
  @view_cache_keys ||= hard_read_view_cache_keys || []
end