Nostrum.Cache.UserCache (Nostrum v0.4.6) View Source

Cache for users.

The ETS table name associated with the User Cache is :users. Besides the methods provided below you can call any other ETS methods on the table.

Example

info = :ets.info(:users)
[..., heir: :none, name: :users, size: 1, ...]
size = info[:size]
1

Link to this section Summary

Functions

Retrieves a user from the cache by id.

Same as get/1, but raises Nostrum.Error.CacheError in case of a failure.

Link to this section Functions

Specs

get(Nostrum.Struct.User.id()) ::
  {:error, atom()} | {:ok, Nostrum.Struct.User.t()}

Retrieves a user from the cache by id.

If successful, returns {:ok, user}. Otherwise, returns {:error, reason}.

Example

case Nostrum.Cache.UserCache.get(1111222233334444) do
  {:ok, user} ->
    "We found " <> user.username
  {:error, _reason} ->
    "No es bueno"
end

Specs

Same as get/1, but raises Nostrum.Error.CacheError in case of a failure.