class Fontist::ValidationCache
Validation cache for storing/reusing validation results. Uses file metadata for automatic cache invalidation. Persisted to disk for fast subsequent validation runs.
Public Instance Methods
Source
# File lib/fontist/validation.rb, line 100 def get(path) return nil unless File.exist?(path) stat = File.stat(path) entries.find do |entry| next unless entry.path == path # Check if file has changed since caching entry.file_size == stat.size && entry.file_mtime == stat.mtime.to_i end end
Get validation result for a path, checking if file has changed
Source
# File lib/fontist/validation.rb, line 114 def set(result) # Remove existing entry for same path @entries = entries.reject { |e| e.path == result.path } @entries << result @generated_at = Time.now.to_i self end
Add or update a validation result
Source
# File lib/fontist/validation.rb, line 123 def stale? return true if @generated_at.nil? (Time.now.to_i - @generated_at) > (24 * 60 * 60) end
Check if cache is stale (older than 24 hours)
Source
# File lib/fontist/validation.rb, line 95 def to_lookup entries.index_by(&:path) end
Build lookup hash for fast O(1) access by path (non-shared state)