class Athena::HTTP::Session::Storage::MetadataBag
inherits Reference
#
Stores metadata about the session itself: when it was created, last used, and the lifetime of its cookie.
Its timestamps use the provided clock, if the Clock component is installed, otherwise the system time.
Included modules
Athena::HTTP::Session::BagInterface
Constants#
CREATED = "c"#
LIFETIME = "l"#
UPDATED = "u"#
Constructors#
.new(storage_key : String = "_athena_meta", update_threshold : Int32 = 0, cookie_lifetime : Int32 = 0, clock : Athena::HTTP::Session::Storage::MetadataBag::Clock | Nil = nil)#
Creates a new bag, persisted under the provided storage_key.
The last used timestamp is only updated once at least update_threshold seconds passed since it was last updated, which avoids writing the session on each request.
The cookie_lifetime is the lifetime of new sessions in seconds, 0 meaning until the browser is closed.
Methods#
#empty? : Bool#
Always returns false, as the metadata is persisted along with the rest of the session.
#lifetime : Int32#
Returns the lifetime of the session's cookie in seconds, 0 meaning until the browser is closed.
#load(pull : JSON::PullParser | Nil) : Nil#
Loads this bag's data from the provided pull parser, positioned at the value persisted under #storage_key.
Resets this bag to empty if pull is nil, i.e. nothing was persisted under it.
#name : String#
Returns the name of this bag, used to retrieve it via AHTTP::Session#bag.
#stamp_new(lifetime : Int32 | Nil = nil) : Nil#
Stamps the session as being created now, optionally with the provided lifetime in seconds.
#storage_key : String#
Returns the key this bag's data is persisted under within the session.
#to_json(builder : JSON::Builder) : Nil#
Writes this bag's data to the provided builder, to be persisted under #storage_key.