class Fbe::Middleware::SqliteStore
def read(key)
-
(Object, nil)
- The cached value parsed from JSON, or nil if not found
Parameters:
-
key
(String
) -- The cache key to read
def read(key) value = perform do |t| t.execute('UPDATE cache SET touched_at = ?2 WHERE key = ?1;', [key, Time.now.utc.iso8601]) t.execute('SELECT value FROM cache WHERE key = ? LIMIT 1;', [key]) end.dig(0, 0) return unless value begin JSON.parse(Zlib::Inflate.inflate(value)) rescue Zlib::Error => e @loog.info("Failed to decompress cached value for key: #{key}, error: #{e.message}, the key will be deleted") delete(key) end end