View Source Nostrum.Cache.MemberCache.ETS (Nostrum v0.7.0)
An ETS-based cache for members.
The supervisor defined by this module will set up the ETS table associated with it.
The default table name under which guilds are cached is nostrum_members
. In
addition to the cache behaviour implementations provided by this module, you
can also call regular ETS table methods on it, such as :ets.info
. Use the
tabname/0
function for retrieving the table name at runtime.
Note that users should not call the functions not related to this specific
implementation of the cache directly. Instead, call the functions of
Nostrum.Cache.MemberCache
directly, which will dispatch to the configured
cache.
Link to this section Summary
Functions
Bulk create a chunk of members for the given guild in the cache.
Get all members for the given user ID.
Returns a specification to start this module under a supervisor.
Add the given member to the given guild in the cache.
Remove the given member from the given guild in the cache.
Get all members for a given guild ID.
Fetch a single member from the cache.
Set up the cache's ETS table.
Get a QLC handle for the entire table.
Start the supervisor.
Retrieve the ETS table name used for the cache.
Update the given member for the given guild in the cache.
Link to this section Functions
Bulk create a chunk of members for the given guild in the cache.
@spec by_user(Nostrum.Struct.Guild.Member.user_id()) :: Enumerable.t({Nostrum.Struct.Guild.id(), Nostrum.Struct.Guild.Member.t()})
Get all members for the given user ID.
The same implementation notes as for get/1
apply for this function.
Returns a specification to start this module under a supervisor.
See Supervisor
.
@spec create(Nostrum.Struct.Guild.id(), map()) :: Nostrum.Struct.Guild.Member.t()
Add the given member to the given guild in the cache.
@spec delete(Nostrum.Struct.Guild.id(), map()) :: {Nostrum.Struct.Guild.id(), Nostrum.Struct.Guild.Member.t()} | :noop
Remove the given member from the given guild in the cache.
@spec get(Nostrum.Struct.Guild.id()) :: Enumerable.t(Nostrum.Struct.Guild.Member.t())
Get all members for a given guild ID.
Note that this implementation uses :ets.safe_fixtable/2
to ensure safe
traversal until the returned stream is exhausted or the calling process
terminates. This also degrades performance for other table operations, and
prevents table deletions from freeing up memory. It is therefore recommended
to finish your business quickly.
@spec get(Nostrum.Struct.Guild.id(), Nostrum.Struct.Guild.Member.user_id()) :: {:ok, Nostrum.Struct.Guild.Member.t()} | {:error, atom()}
Fetch a single member from the cache.
Set up the cache's ETS table.
@spec qlc_handle() :: :qlc.query_handle()
Get a QLC handle for the entire table.
Start the supervisor.
@spec tabname() :: atom()
Retrieve the ETS table name used for the cache.
@spec update(Nostrum.Struct.Guild.id(), map()) :: {Nostrum.Struct.Guild.id(), Nostrum.Struct.Guild.Member.t() | nil, Nostrum.Struct.Guild.Member.t()}
Update the given member for the given guild in the cache.