pub struct Cache(_);
Expand description

The Discord cache

This is a wrapper over PgPool, you can use Cache::pg to get the inner PgPool, see its documentation for more info

Indexing

Most ID and name columns are indexed, you can inspect the database to see which columns are indexed, you can also create your own indexes using the inner PgPool, if you think there’s a missing index, please create an issue

Implementations

Create a new cache using the given URL

Refer to [sqlx::postgres::PgConnectOptions] for the URL format

This only clears the tables about Sparkle Cache, meaning any other custom tables are persistent

Errors

Returns the error SQLx returns when the database connection failed or the init.sql script failed to run

Return a reference to the inner PgPool for the cache, so that you can use it in custom queries

Make sure the names of tables or indexes you create don’t collide with the ones created by this crate

Example
use sparkle_cache_postgres::Cache;
use sqlx::query;
query!("CREATE TABLE IF NOT EXISTS members_ext (id bigint, age smallint)")
    .execute(cache.pg())
    .await?;

Trait Implementations

The error type the backend returns, for example sqlx::Error
Set or replace the current user information of the bot
Add or replace a channel in the cache
Remove a channel from the cache
Remove a guild’s channels from the cache Read more
Add a permission overwrite to the cache Read more
Remove a channel’s permission overwrites from the cache Read more
Add or replace a message in the cache
Remove a message from the cache
Add an embed to the cache
Remove an embed from the cache
Add an embed field to the cache Read more
Remove an embed’s fields from the cache Read more
Get embeds of a message by its ID Read more
Get fields of an embed by its ID Read more
Add an attachment to the cache
Remove a message’s attachments from the cache Read more
Add a reaction to the cache Read more
Remove a reaction from the cache
Remove a message’s reactions of the given emoji from the cache Read more
Remove a message’s reactions from the cache Read more
Add or replace a member in the cache Read more
Remove a member from the cache
Remove a guild’s members from the cache Read more
Add or replace a presence in the cache Read more
Remove a presence from the cache
Remove a guild’s presences from the cache Read more
Add an activity to the cache Read more
Remove a user’s activities from the cache Read more
Add or replace a guild in the cache
Remove a channel from the cache
Add a role to the cache Read more
Update roles in the cache Read more
Remove a role from the cache
Remove a guild’s roles from the cache Read more
Remove a member’s roles from the cache Read more
Add or replace an emoji in the cache
Remove an emoji from the cache
Remove a guild’s emojis from the cache Read more
Add or replace a sticker in the cache Read more
Remove a message’s stickers from the cache Read more
Remove a guild’s stickers from the cache Read more
Add or replace a stage instance in the cache
Remove a stage instance from the cache
Remove a guild’s stage instance from the cache Read more
Get the current user information of the bot Read more
Get a cached channel or thread by its ID Read more
Get a cached permission overwrites of a channel by its ID
Get a guild’s channels and threads by its ID
Get a cached message by its ID Read more
Get cached attachments of a message by its ID
Get cached reactions of a message by its ID
Get cached stickers of a message by its ID
Get a channel’s most recent limit messages by its ID Read more
Get a cached member by its guild ID and user ID
Get cached roles of a member by their ID
Get cached presence of a member by their ID
Get cached activities of a member by their ID
Get a guild’s members by its ID
Get a cached guild by its ID
Get a cached role by its ID
Get a guild’s roles by its ID
Get a cached emoji by its ID
Get a guild’s emojis by its ID
Get a cached sticker by its ID
Get a guild’s stickers by its ID
Get a cached stage instance by its ID
Update the cache with the given event, should be called for every event to keep the cache valid Read more
Get permissions of the current user in the given channel Read more
Get permissions of the current user in the given guild Read more
Get the permissions of the given user and channel Read more
Get the permissions of the given user and guild Read more
Get cached embeds of a message by its ID
Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more