Rivet.Ident.User.Cache (rivet_ident v4.0.0)

Copy Markdown View Source

Used by websockets token authentication. Very short term cache to efficiently load ~30 websockets all at once for a single dashboard.

Summary

Functions

Returns a specification to start this module under a supervisor.

Return the value of a key in an idiomatic tuple

Similar to get, but call a function to lookup the value if it isn't in the cache.

Store anything for a certain amount of time or forever if no keep alive time specified

Retrieve anything by its key using the raw :ets.lookup call. less idiomatic than get, but includes rescue for unexpected results that raise an error, instead turning it into :error after logging the reason.

Count of items in the cache.

Start scheduling the works for clearing the cache. This method should be called before performing any operation.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

clear()

delete(key)

get(key)

Return the value of a key in an idiomatic tuple

get_through(key, func)

Similar to get, but call a function to lookup the value if it isn't in the cache.

get_user(id)

insert(key, value, keepalive \\ :infinity)

@spec insert(any(), any(), pos_integer() | :infinity) :: true | {:error, String.t()}

Store anything for a certain amount of time or forever if no keep alive time specified

lookup(key)

Retrieve anything by its key using the raw :ets.lookup call. less idiomatic than get, but includes rescue for unexpected results that raise an error, instead turning it into :error after logging the reason.

persist(user)

size()

Count of items in the cache.

start_link(_)

Start scheduling the works for clearing the cache. This method should be called before performing any operation.

Returns {:ok, PID}.