Class: SolidObserver::Services::CacheOperations
- Inherits:
-
Object
- Object
- SolidObserver::Services::CacheOperations
- Defined in:
- lib/solid_observer/services/cache_operations.rb
Constant Summary collapse
- MESSAGES =
{ clear: { confirmation: "Clear all SolidCache entries? This evicts cached application data and may slow requests while the cache rebuilds. This cannot be undone.", success: "Cache cleared successfully.", failure: "Cache clear failed. SolidCache is unavailable or rejected the operation." }.freeze, prune: { success: "Expired cache entries pruned successfully.", failure: "Cache prune failed. SolidCache is unavailable or rejected the operation." }.freeze, unavailable: "Cache controls are unavailable because SolidCache is not enabled or not detected." }.freeze
Class Method Summary collapse
- .available? ⇒ Boolean
- .clear ⇒ Object
- .message(operation, key = nil) ⇒ Object
- .prune ⇒ Object
- .unavailable_message ⇒ Object
Instance Method Summary collapse
Class Method Details
.available? ⇒ Boolean
20 21 22 |
# File 'lib/solid_observer/services/cache_operations.rb', line 20 def available? new.available? end |
.clear ⇒ Object
24 25 26 |
# File 'lib/solid_observer/services/cache_operations.rb', line 24 def clear new.clear end |
.message(operation, key = nil) ⇒ Object
32 33 34 35 36 |
# File 'lib/solid_observer/services/cache_operations.rb', line 32 def (operation, key = nil) return MESSAGES.fetch(:unavailable) if operation == :unavailable MESSAGES.fetch(operation).fetch(key) end |
.prune ⇒ Object
28 29 30 |
# File 'lib/solid_observer/services/cache_operations.rb', line 28 def prune new.prune end |
.unavailable_message ⇒ Object
38 39 40 |
# File 'lib/solid_observer/services/cache_operations.rb', line 38 def (:unavailable) end |
Instance Method Details
#available? ⇒ Boolean
43 44 45 |
# File 'lib/solid_observer/services/cache_operations.rb', line 43 def available? SolidObserver.config.solid_cache_enabled? && compatible_store? end |
#clear ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/solid_observer/services/cache_operations.rb', line 47 def clear = self.class return {ok: false, message: .} unless available? perform_operation( :clear, success_message: .(:clear, :success), failure_message: .(:clear, :failure) ) do cache_store.clear end end |
#prune ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/solid_observer/services/cache_operations.rb', line 60 def prune = self.class return {ok: false, message: .} unless available? perform_operation( :prune, success_message: .(:prune, :success), failure_message: .(:prune, :failure) ) do prune_with_fallback end end |