Nebulex v1.1.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 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
Link to this function
expire_at(ttl) View Source
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
Link to this function
remaining_ttl(expire_at)
View Source
remaining_ttl(expire_at)
View Source
remaining_ttl(object_or_ttl :: Nebulex.Object.t() | integer() | nil) ::
timeout()
remaining_ttl(object_or_ttl :: Nebulex.Object.t() | integer() | nil) :: timeout()
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 Source
ts(datetime \\ DateTime.utc_now())
View Source
ts(datetime :: Calendar.datetime()) :: integer()
ts(datetime :: Calendar.datetime()) :: integer()
Wrapper for DateTime.to_unix/2.
Example
iex> 1_464_096_368 |> DateTime.from_unix!() |> Nebulex.Object.ts()
1464096368