Module: Fontist::Memoizable

Defined in:
lib/fontist/memoizable.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
# File 'lib/fontist/memoizable.rb', line 3

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#clear_memo_cacheObject



21
22
23
24
25
26
27
28
# File 'lib/fontist/memoizable.rb', line 21

def clear_memo_cache
  # Clear all tracked cache keys from disk and memory
  @memo_cache_keys&.each do |key|
    Fontist::Cache::Manager.delete(key)
  end
  @memo_cache = {}
  @memo_cache_keys = Set.new
end

#generate_memo_cache_key(method_name, args, key_proc) ⇒ Object

Instance methods for memoization support



8
9
10
11
12
13
14
# File 'lib/fontist/memoizable.rb', line 8

def generate_memo_cache_key(method_name, args, key_proc)
  if key_proc
    key_proc.call(*args)
  else
    "#{method_name}:#{args.hash}"
  end
end

#memo_cache_expired?(_cached) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
# File 'lib/fontist/memoizable.rb', line 16

def memo_cache_expired?(_cached)
  # Cache::Manager handles TTL internally
  false
end