struct Marten::Cache::Entry
- Marten::Cache::Entry
- Struct
- Value
- Object
Overview
Represents a cache entry.
Cache entries are associated with a value, an optional version, and an optional expiration timestamp. These entries are serialized using MessagePack before being written to the cache store: when reading from the cache, entries are "reconstructed" by deserializing the corresponding raw MessagePack binary value.
Defined in:
marten/cache/entry.crConstructors
-
.new(value : String, version : Int32 | Nil = nil, expires_in : Time::Span | Nil = nil)
Creates a new cache entry for the specified value and options.
-
.new(value : String, expires_at : Float64 | Nil = nil, version : Int32 | Nil = nil)
Creates a new cache entry for the specified value and options.
Class Method Summary
-
.unpack(packed : String)
Unpacks a serialized entry value and returns the corresponding
Entry
object.
Instance Method Summary
-
#expired?
Returns
true
if the entry is expired. -
#expires_at : Float64?
Returns the expiration timestamp for the entry.
-
#expires_at=(expires_at : Float64 | Nil)
Allows to set the expiration timestamp for the entry.
-
#mismatched?(version : Int32 | Nil)
Returns
true
if there is a version mismatch between the entry version and the specified version. -
#pack : String
Packs the entry object and returns the corresponding serialized value.
-
#value : String
Returns the entry value.
-
#version : Int32?
Returns the entry version.
Constructor Detail
Creates a new cache entry for the specified value and options.
Creates a new cache entry for the specified value and options.
Class Method Detail
Unpacks a serialized entry value and returns the corresponding Entry
object.
Instance Method Detail
Returns true
if there is a version mismatch between the entry version and the specified version.