struct

Marten::Cache::Entry

Inherits Struct / Value / Object

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.

Constructors

new(value : String, version : Int32 | Nil = nil, expires_in : Time::Span | Nil = nil)

Creates a new cache entry for the specified value and options.

Source
new(value : String, expires_at : Float64 | Nil = nil, version : Int32 | Nil = nil)

Creates a new cache entry for the specified value and options.

Source

Class methods

unpack(packed : String)

Unpacks a serialized entry value and returns the corresponding Entry object.

Source

Instance methods

expired?

Returns true if the entry is expired.

Source
expires_at

Returns the expiration timestamp for the entry.

Source
expires_at=(expires_at : Float64 | Nil)

Allows to set the expiration timestamp for the entry.

Source
mismatched?(version : Int32 | Nil)

Returns true if there is a version mismatch between the entry version and the specified version.

Source
pack

Packs the entry object and returns the corresponding serialized value.

Source
value

Returns the entry value.

Source
version

Returns the entry version.

Source