struct Marten::Cache::Entry

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.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

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

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


[View source]
def self.new(value : String, expires_at : Float64 | Nil = nil, version : Int32 | Nil = nil) #

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


[View source]

Class Method Detail

def self.unpack(packed : String) #

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


[View source]

Instance Method Detail

def expired? #

Returns true if the entry is expired.


[View source]
def expires_at : Float64? #

Returns the expiration timestamp for the entry.


[View source]
def expires_at=(expires_at : Float64 | Nil) #

Allows to set the expiration timestamp for the entry.


[View source]
def mismatched?(version : Int32 | Nil) #

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


[View source]
def pack : String #

Packs the entry object and returns the corresponding serialized value.


[View source]
def value : String #

Returns the entry value.


[View source]
def version : Int32? #

Returns the entry version.


[View source]