Elixir v0.2.1 Nostrum.Cache.UserCache

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

Summary

Functions

Retrieves a user from the cache

Retrieves a user from the cache

Functions

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

Retrieves a user from the cache.

get/1 requires a keyword list as its only argument.

Returns {:ok, Nostrum.Struct.User.t} if found, {:error, atom} otherwise.

Example

case Nostrum.Cache.User.get(id: 1111222233334444) do
  {:ok, user} ->
    "We found " <> user.username
  {:error, _reason} ->
    "No es bueno"
end
get!(list)
get!([{:id, integer}]) :: no_return | Nostrum.Struct.User.t

Retrieves a user from the cache.

See get/1 for use and examples.

Returns Nostrum.Struct.User.t if found. Raises Nostrum.Error.CahceError if not found.

remove_struct_key(map)