View Source Nostrum.Cache.PresenceCache.ETS (Nostrum v0.7.0-rc1)

ETS-based cache for user presences.

The ETS table name associated with the User Cache is presences. Besides the methods provided below you can call any other ETS methods on the table. If you need to access the name of the presence cache's table programmatically, use the tabname/0 function instead of hardcoding it in your application.

example

Example

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

Link to this section Summary

Functions

Bulk create multiple presences in the cache.

Returns a specification to start this module under a supervisor.

Add the given presence data to the cache.

Retrieves a presence for a user from the cache by guild and id.

Set up the cache's ETS table.

Start the supervisor.

Return the ETS table name used for this cache.

Update the given presence data in the cache.

Link to this section Functions

Link to this function

bulk_create(guild_id, presences)

View Source (since 0.5.0)
@spec bulk_create(Nostrum.Struct.Guild.id(), [map()]) :: :ok

Bulk create multiple presences in the cache.

Link to this function

child_spec(init_arg)

View Source (since 0.5.0)

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

create(presence)

View Source (since 0.5.0)
@spec create(map()) :: :ok

Add the given presence data to the cache.

Link to this function

get(user_id, guild_id)

View Source (since 0.5.0)
@spec get(Nostrum.Struct.User.id(), Nostrum.Struct.Guild.id()) ::
  {:error, :presence_not_found} | {:ok, map()}

Retrieves a presence for a user from the cache by guild and id.

Link to this function

init(init_arg)

View Source (since 0.5.0)

Set up the cache's ETS table.

Link to this function

start_link(init_arg)

View Source (since 0.5.0)

Start the supervisor.

@spec tabname() :: atom()

Return the ETS table name used for this cache.

Link to this function

update(presence)

View Source (since 0.5.0)
@spec update(map()) :: {Nostrum.Struct.Guild.id(), nil | map(), map()} | :noop

Update the given presence data in the cache.