View Source Nostrum.Cache.UserCache.Mnesia (Nostrum v0.10.0)

An Mnesia-based cache for users.

Please note that this module is only compiled if Mnesia is available on your system. See the Mnesia section of the State documentation for more information.

To retrieve the table name used by this cache, use table/0.

Summary

Functions

Bulk create a chunk of users in the cache.

Returns a specification to start this module under a supervisor.

Clear any objects in the cache.

Create a user from upstream data.

Remove the given user from cache.

Retrieve a user from the cache.

Set up the cache's Mnesia table.

Start the supervisor.

Retrieve the Mnesia table name used for the cache.

Drop the table used for caching.

Update a User if it exists in the cache.

Wrap QLC operations in a transaction.

Functions

Link to this function

bulk_create(users)

View Source (since 0.8.0)

Bulk create a chunk of users in the cache.

Link to this function

child_spec(init_arg)

View Source (since 0.8.0)

Returns a specification to start this module under a supervisor.

See Supervisor.

@spec clear() :: :ok

Clear any objects in the cache.

Link to this function

create(payload)

View Source (since 0.8.0)
@spec create(map()) :: Nostrum.Struct.User.t()

Create a user from upstream data.

Link to this function

delete(user_id)

View Source (since 0.8.0)
@spec delete(Nostrum.Struct.User.id()) :: Nostrum.Struct.User.t() | :noop

Remove the given user from cache.

Link to this function

get(user_id)

View Source (since 0.8.0)
@spec get(Nostrum.Struct.User.id()) ::
  {:ok, Nostrum.Struct.User.t()} | {:error, :user_not_found}

Retrieve a user from the cache.

Link to this function

init(init_arg)

View Source (since 0.8.0)

Set up the cache's Mnesia table.

Link to this function

start_link(init_arg)

View Source (since 0.8.0)

Start the supervisor.

@spec table() :: atom()

Retrieve the Mnesia table name used for the cache.

Link to this function

teardown()

View Source (since 0.8.0)
@spec teardown() :: {:atomic, :ok} | {:aborted, term()}

Drop the table used for caching.

Link to this function

update(payload)

View Source (since 0.8.0)
@spec update(map()) :: {Nostrum.Struct.User.t() | nil, Nostrum.Struct.User.t()}

Update a User if it exists in the cache.

Link to this function

wrap_query(fun)

View Source (since 0.8.0)

Wrap QLC operations in a transaction.