Class: Fontist::Cache::Manager
- Inherits:
-
Object
- Object
- Fontist::Cache::Manager
- Defined in:
- lib/fontist/cache/manager.rb
Overview
Central cache manager for font index caching operations
Class Method Summary collapse
-
.cache_dir ⇒ Object
Cache directory is determined lazily to avoid initialization issues.
- .clear(namespace: nil) ⇒ Object
- .delete(key, namespace: nil) ⇒ Object
-
.get(key, namespace: nil) ⇒ Object
Public API for cache operations.
-
.get_directory_fonts(directory_path) ⇒ Object
Convenience methods for directory-level caching.
- .set(key, value, ttl: nil, namespace: nil) ⇒ Object
- .set_directory_fonts(directory_path, fonts) ⇒ Object
Class Method Details
.cache_dir ⇒ Object
Cache directory is determined lazily to avoid initialization issues
12 13 14 |
# File 'lib/fontist/cache/manager.rb', line 12 def cache_dir @cache_dir ||= Fontist.root_path.join("cache") end |
.clear(namespace: nil) ⇒ Object
29 30 31 32 33 |
# File 'lib/fontist/cache/manager.rb', line 29 def clear(namespace: nil) return clear_all unless namespace store(namespace).clear end |
.delete(key, namespace: nil) ⇒ Object
25 26 27 |
# File 'lib/fontist/cache/manager.rb', line 25 def delete(key, namespace: nil) store(namespace).delete(key) end |
.get(key, namespace: nil) ⇒ Object
Public API for cache operations
17 18 19 |
# File 'lib/fontist/cache/manager.rb', line 17 def get(key, namespace: nil) store(namespace).get(key) end |
.get_directory_fonts(directory_path) ⇒ Object
Convenience methods for directory-level caching
36 37 38 |
# File 'lib/fontist/cache/manager.rb', line 36 def get_directory_fonts(directory_path) get("directory:#{directory_path}", namespace: :indexes) end |
.set(key, value, ttl: nil, namespace: nil) ⇒ Object
21 22 23 |
# File 'lib/fontist/cache/manager.rb', line 21 def set(key, value, ttl: nil, namespace: nil) store(namespace).set(key, value, ttl: ttl) end |
.set_directory_fonts(directory_path, fonts) ⇒ Object
40 41 42 43 |
# File 'lib/fontist/cache/manager.rb', line 40 def set_directory_fonts(directory_path, fonts) set("directory:#{directory_path}", fonts, ttl: 3600, namespace: :indexes) end |