Nebulex v1.2.0 Nebulex.Object View Source
Defines a Cache Object.
This is the struct used by the caches to store and retrieve data.
Link to this section Summary
Functions
Returns the UNIX timestamp in seconds for the given ttl
.
Returns whether the given object
has expired or not.
Returns the remaining time to live for the given timestamp.
Wrapper for DateTime.to_unix/2
.
Link to this section Types
Link to this section Functions
Returns the UNIX timestamp in seconds for the given ttl
.
Example
iex> expire_at = Nebulex.Object.expire_at(10)
iex> expire_at - Nebulex.Object.ts()
10
Returns whether the given object
has expired or not.
Example
iex> Nebulex.Object.expired?(%Nebulex.Object{})
false
Returns the remaining time to live for the given timestamp.
Example
iex> expire_at = Nebulex.Object.expire_at(10)
iex> Nebulex.Object.remaining_ttl(expire_at)
10
Link to this function
ts(datetime \\ DateTime.utc_now())
View Sourcets(datetime :: Calendar.datetime()) :: integer()
Wrapper for DateTime.to_unix/2
.
Example
iex> 1_464_096_368 |> DateTime.from_unix!() |> Nebulex.Object.ts()
1464096368