Module: SolidCacheDashboard::CacheEntry
- Defined in:
- lib/solid_cache_dashboard/cache_entry.rb
Constant Summary collapse
- ACTIVE =
Constants
:active- EXPIRED =
:expired- STATUSES =
[ACTIVE, EXPIRED]
- STATUS_COLORS =
{ ACTIVE => "green", EXPIRED => "amber" }
Class Method Summary collapse
-
.determine_expiration_status(entry) ⇒ Object
Calculates the expiration status for a cache entry.
-
.estimate_overhead(entry) ⇒ Object
Estimates the overhead size of a cache entry based on the SolidCache::Entry constants.
-
.size_breakdown(entry) ⇒ Object
Returns size breakdown information for a given entry.
-
.status_color(status) ⇒ Object
Returns the appropriate color for the given status.
Class Method Details
.determine_expiration_status(entry) ⇒ Object
Calculates the expiration status for a cache entry
20 21 22 23 |
# File 'lib/solid_cache_dashboard/cache_entry.rb', line 20 def self.determine_expiration_status(entry) return ACTIVE unless entry.respond_to?(:expires_at) && entry.expires_at entry.expires_at <= Time.now ? EXPIRED : ACTIVE end |
.estimate_overhead(entry) ⇒ Object
Estimates the overhead size of a cache entry based on the SolidCache::Entry constants
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/solid_cache_dashboard/cache_entry.rb', line 35 def self.estimate_overhead(entry) if defined?(SolidCache.configuration) && SolidCache.configuration.respond_to?(:encrypt?) && SolidCache.configuration.encrypt? estimated_encryption_overhead = defined?(SolidCache::Entry::ESTIMATED_ENCRYPTION_OVERHEAD) ? SolidCache::Entry::ESTIMATED_ENCRYPTION_OVERHEAD : 170 estimated_row_overhead = defined?(SolidCache::Entry::ESTIMATED_ROW_OVERHEAD) ? SolidCache::Entry::ESTIMATED_ROW_OVERHEAD : 140 estimated_row_overhead + estimated_encryption_overhead else defined?(SolidCache::Entry::ESTIMATED_ROW_OVERHEAD) ? SolidCache::Entry::ESTIMATED_ROW_OVERHEAD : 140 end end |
.size_breakdown(entry) ⇒ Object
Returns size breakdown information for a given entry
26 27 28 29 30 31 32 |
# File 'lib/solid_cache_dashboard/cache_entry.rb', line 26 def self.size_breakdown(entry) { key_size: entry.key.to_s.bytesize, value_size: entry.value.to_s.bytesize, overhead_size: estimate_overhead(entry) } end |
.status_color(status) ⇒ Object
Returns the appropriate color for the given status
15 16 17 |
# File 'lib/solid_cache_dashboard/cache_entry.rb', line 15 def self.status_color(status) STATUS_COLORS[status] || "zinc" end |