Nebulex v1.0.1 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

Link to this section Types

Link to this type

t() View Source
t() :: %Nebulex.Object{
  expire_at: integer() | nil,
  key: any(),
  value: any(),
  version: any()
}

Link to this section Functions

Link to this function

expire_at(ttl) View Source
expire_at(ttl :: timeout() | nil) :: integer() | nil

Returns the UNIX timestamp in seconds for the given ttl.

Example

iex> Nebulex.Object.expire_at(10)
1539787704
Link to this function

remaining_ttl(expire_at) View Source
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