Skip to content

sake.redis#

Redis based implementations of Sake's clients.

DEFAULT_EXPIRE module-attribute #

DEFAULT_EXPIRE = 3600000

The default expire time (in milliseconds) used for expiring resources of 60 minutes.

DEFAULT_FAST_EXPIRE module-attribute #

DEFAULT_FAST_EXPIRE = 300000

The default expire time (in milliseconds) used for expiring resources quickly of 5 minutes.

DEFAULT_INVITE_EXPIRE module-attribute #

DEFAULT_INVITE_EXPIRE = 2592000000

A special case month long default expire time for invite entries without a set "expire_at".

DEFAULT_SLOW_EXPIRE module-attribute #

DEFAULT_SLOW_EXPIRE = 604800

The default expire time (in milliseconds) used for gateway-event deleted resources (1 week).

EmojiCache #

Bases: _Reference, RefEmojiCache

Redis implementation of sake.abc.EmojiCache.

app property #

app

The Hikari client this resource client is tied to.

This is used to build models with a app attribute.

config property #

config

This client's settings.

default_expire property #

default_expire

The default expire time used for fields with no actual lifetime.

If this is None then these cases will have no set expire after.

event_manager property #

event_manager

The event manager this resource client is using for managing state.

__init__ #

__init__(address, app, event_manager=None, *, config=None, default_expire=DEFAULT_SLOW_EXPIRE, event_managed=False, password=None, max_connections_per_db=5, dumps=lambda obj: json.dumps(obj).encode(), loads=json.loads)

Initialise a resource client.

Parameters:

  • app (Union[RESTAware, RESTClient]) –

    The Hikari app or REST client all the models returned by this client should be bound to.

  • address (str) –

    The address to use to connect to the Redis backend server this resource is linked to.

    E.g: - "redis://[[username]:[password]]@localhost:6379" - "rediss://[[username]:[password]]@localhost:6379" - "unix://[[username]:[password]]@/path/to/socket.sock"

    Three URL schemes are supported: - redis://: creates a TCP socket connection. See more at: https://www.iana.org/assignments/uri-schemes/prov/redis - rediss://: creates a SSL wrapped TCP socket connection. See more at: https://www.iana.org/assignments/uri-schemes/prov/rediss - unix://: creates a Unix Domain Socket connection.

  • event_manager (Optional[EventManager], default: None ) –

    The event manager to bind this resource client to.

    If provided then this client will automatically manage resources based on received gateway events.

  • event_managed (bool, default: False ) –

    Whether the client should be started and stopped based on the attached event_manager's lifetime events.

  • password (Optional[str], default: None ) –

    The password to use to connect to the backend Redis server.

Raises:

  • ValueError

    When event_managed is True and event_manager wasn't passed.

add_to_tanjun #

add_to_tanjun(client, /, *, trust_get_for=None, tanjun_managed=False)

Add this Redis client to a Tanjun client.

This method will register type dependencies for the resources implemented by it (including tanjun.dependencies.async_cache compatible adapters which will allow Tanjun extensions and standard utility such as converters to be aware of this cache).

The type dependencies this will register depend on which resources are implemented but are as follows for each standard resource implementation:

Parameters:

Raises:

  • RuntimeError

    If this is called in an environment without Tanjun.

all_indexes #

all_indexes()

Get a set of all the Redis client indexes this is using.

Note

This accounts for index overrides.

Returns:

  • MutableSet[ResourceIndex | int]

    A set of all the Redis client indexes this is using.

all_intents classmethod #

all_intents()

The intents required for a client to be sufficient event managed.

If not all these intents are present in the linked event manager then this client won't be able to reliably fill and manage the linked redis database(s).

dump #

dump(data)

Serialize a dict object representation into the form to be stored.

Parameters:

  • data (_ObjectT) –

    The dict object to serialize.

Returns:

  • bytes

    The object serialized as bytes.

get_index_override #

get_index_override(index)

Get the override set for an index.

Parameters:

Returns:

  • int | None

    The found override if set, else None.

load #

load(data)

Deserialize a bytes representation to a dict object.

Parameters:

  • data (bytes) –

    The bytes representation from the database to a dict object.

Returns:

  • dict[str, Any]

    The deserialized dict object.

with_index_override #

with_index_override(index, /, *, override=None)

Add an index override.

Parameters:

  • index (ResourceIndex) –

    The index to override.

  • override (Optional[int], default: None ) –

    The override to set.

    If this is left at None then any previous override is unset. This will decide which Redis database is targeted for a resource.

GuildCache #

Bases: ResourceClient, GuildCache

Redis implementation of sake.abc.GuildCache.

app property #

app

The Hikari client this resource client is tied to.

This is used to build models with a app attribute.

config property #

config

This client's settings.

default_expire property #

default_expire

The default expire time used for fields with no actual lifetime.

If this is None then these cases will have no set expire after.

event_manager property #

event_manager

The event manager this resource client is using for managing state.

__init__ #

__init__(address, app, event_manager=None, *, config=None, default_expire=DEFAULT_SLOW_EXPIRE, event_managed=False, password=None, max_connections_per_db=5, dumps=lambda obj: json.dumps(obj).encode(), loads=json.loads)

Initialise a resource client.

Parameters:

  • app (Union[RESTAware, RESTClient]) –

    The Hikari app or REST client all the models returned by this client should be bound to.

  • address (str) –

    The address to use to connect to the Redis backend server this resource is linked to.

    E.g: - "redis://[[username]:[password]]@localhost:6379" - "rediss://[[username]:[password]]@localhost:6379" - "unix://[[username]:[password]]@/path/to/socket.sock"

    Three URL schemes are supported: - redis://: creates a TCP socket connection. See more at: https://www.iana.org/assignments/uri-schemes/prov/redis - rediss://: creates a SSL wrapped TCP socket connection. See more at: https://www.iana.org/assignments/uri-schemes/prov/rediss - unix://: creates a Unix Domain Socket connection.

  • event_manager (Optional[EventManager], default: None ) –

    The event manager to bind this resource client to.

    If provided then this client will automatically manage resources based on received gateway events.

  • event_managed (bool, default: False ) –

    Whether the client should be started and stopped based on the attached event_manager's lifetime events.

  • password (Optional[str], default: None ) –

    The password to use to connect to the backend Redis server.

Raises:

  • ValueError

    When event_managed is True and event_manager wasn't passed.

add_to_tanjun #

add_to_tanjun(client, /, *, trust_get_for=None, tanjun_managed=False)

Add this Redis client to a Tanjun client.

This method will register type dependencies for the resources implemented by it (including tanjun.dependencies.async_cache compatible adapters which will allow Tanjun extensions and standard utility such as converters to be aware of this cache).

The type dependencies this will register depend on which resources are implemented but are as follows for each standard resource implementation:

Parameters:

Raises:

  • RuntimeError

    If this is called in an environment without Tanjun.

all_indexes #

all_indexes()

Get a set of all the Redis client indexes this is using.

Note

This accounts for index overrides.

Returns:

  • MutableSet[ResourceIndex | int]

    A set of all the Redis client indexes this is using.

all_intents classmethod #

all_intents()

The intents required for a client to be sufficient event managed.

If not all these intents are present in the linked event manager then this client won't be able to reliably fill and manage the linked redis database(s).

dump #

dump(data)

Serialize a dict object representation into the form to be stored.

Parameters:

  • data (_ObjectT) –

    The dict object to serialize.

Returns:

  • bytes

    The object serialized as bytes.

get_index_override #

get_index_override(index)

Get the override set for an index.

Parameters:

Returns:

  • int | None

    The found override if set, else None.

load #

load(data)

Deserialize a bytes representation to a dict object.

Parameters:

  • data (bytes) –

    The bytes representation from the database to a dict object.

Returns:

  • dict[str, Any]

    The deserialized dict object.

with_index_override #

with_index_override(index, /, *, override=None)

Add an index override.

Parameters:

  • index (ResourceIndex) –

    The index to override.

  • override (Optional[int], default: None ) –

    The override to set.

    If this is left at None then any previous override is unset. This will decide which Redis database is targeted for a resource.

GuildChannelCache #

Bases: _Reference, RefGuildChannelCache

Redis implementation of sake.abc.RefGuildChannelCache.

app property #

app

The Hikari client this resource client is tied to.

This is used to build models with a app attribute.

config property #

config

This client's settings.

default_expire property #

default_expire

The default expire time used for fields with no actual lifetime.

If this is None then these cases will have no set expire after.

event_manager property #

event_manager

The event manager this resource client is using for managing state.

__init__ #

__init__(address, app, event_manager=None, *, config=None, default_expire=DEFAULT_SLOW_EXPIRE, event_managed=False, password=None, max_connections_per_db=5, dumps=lambda obj: json.dumps(obj).encode(), loads=json.loads)

Initialise a resource client.

Parameters:

  • app (Union[RESTAware, RESTClient]) –

    The Hikari app or REST client all the models returned by this client should be bound to.

  • address (str) –

    The address to use to connect to the Redis backend server this resource is linked to.

    E.g: - "redis://[[username]:[password]]@localhost:6379" - "rediss://[[username]:[password]]@localhost:6379" - "unix://[[username]:[password]]@/path/to/socket.sock"

    Three URL schemes are supported: - redis://: creates a TCP socket connection. See more at: https://www.iana.org/assignments/uri-schemes/prov/redis - rediss://: creates a SSL wrapped TCP socket connection. See more at: https://www.iana.org/assignments/uri-schemes/prov/rediss - unix://: creates a Unix Domain Socket connection.

  • event_manager (Optional[EventManager], default: None ) –

    The event manager to bind this resource client to.

    If provided then this client will automatically manage resources based on received gateway events.

  • event_managed (bool, default: False ) –

    Whether the client should be started and stopped based on the attached event_manager's lifetime events.

  • password (Optional[str], default: None ) –

    The password to use to connect to the backend Redis server.

Raises:

  • ValueError

    When event_managed is True and event_manager wasn't passed.

add_to_tanjun #

add_to_tanjun(client, /, *, trust_get_for=None, tanjun_managed=False)

Add this Redis client to a Tanjun client.

This method will register type dependencies for the resources implemented by it (including tanjun.dependencies.async_cache compatible adapters which will allow Tanjun extensions and standard utility such as converters to be aware of this cache).

The type dependencies this will register depend on which resources are implemented but are as follows for each standard resource implementation:

Parameters:

Raises:

  • RuntimeError

    If this is called in an environment without Tanjun.

all_indexes #

all_indexes()

Get a set of all the Redis client indexes this is using.

Note

This accounts for index overrides.

Returns:

  • MutableSet[ResourceIndex | int]

    A set of all the Redis client indexes this is using.

all_intents classmethod #

all_intents()

The intents required for a client to be sufficient event managed.

If not all these intents are present in the linked event manager then this client won't be able to reliably fill and manage the linked redis database(s).

dump #

dump(data)

Serialize a dict object representation into the form to be stored.

Parameters:

  • data (_ObjectT) –

    The dict object to serialize.

Returns:

  • bytes

    The object serialized as bytes.

get_index_override #

get_index_override(index)

Get the override set for an index.

Parameters:

Returns:

  • int | None

    The found override if set, else None.

load #

load(data)

Deserialize a bytes representation to a dict object.

Parameters:

  • data (bytes) –

    The bytes representation from the database to a dict object.

Returns:

  • dict[str, Any]

    The deserialized dict object.

with_index_override #

with_index_override(index, /, *, override=None)

Add an index override.

Parameters:

  • index (ResourceIndex) –

    The index to override.

  • override (Optional[int], default: None ) –

    The override to set.

    If this is left at None then any previous override is unset. This will decide which Redis database is targeted for a resource.

InviteCache #

Bases: ResourceClient, InviteCache

Redis implementation of sake.abc.InviteCache.

app property #

app

The Hikari client this resource client is tied to.

This is used to build models with a app attribute.

config property #

config

This client's settings.

default_expire property #

default_expire

The default expire time used for fields with no actual lifetime.

If this is None then these cases will have no set expire after.

event_manager property #

event_manager

The event manager this resource client is using for managing state.

__init__ #

__init__(address, app, event_manager=None, *, config=None, default_expire=DEFAULT_SLOW_EXPIRE, event_managed=False, password=None, max_connections_per_db=5, dumps=lambda obj: json.dumps(obj).encode(), loads=json.loads)

Initialise a resource client.

Parameters:

  • app (Union[RESTAware, RESTClient]) –

    The Hikari app or REST client all the models returned by this client should be bound to.

  • address (str) –

    The address to use to connect to the Redis backend server this resource is linked to.

    E.g: - "redis://[[username]:[password]]@localhost:6379" - "rediss://[[username]:[password]]@localhost:6379" - "unix://[[username]:[password]]@/path/to/socket.sock"

    Three URL schemes are supported: - redis://: creates a TCP socket connection. See more at: https://www.iana.org/assignments/uri-schemes/prov/redis - rediss://: creates a SSL wrapped TCP socket connection. See more at: https://www.iana.org/assignments/uri-schemes/prov/rediss - unix://: creates a Unix Domain Socket connection.

  • event_manager (Optional[EventManager], default: None ) –

    The event manager to bind this resource client to.

    If provided then this client will automatically manage resources based on received gateway events.

  • event_managed (bool, default: False ) –

    Whether the client should be started and stopped based on the attached event_manager's lifetime events.

  • password (Optional[str], default: None ) –

    The password to use to connect to the backend Redis server.

Raises:

  • ValueError

    When event_managed is True and event_manager wasn't passed.

add_to_tanjun #

add_to_tanjun(client, /, *, trust_get_for=None, tanjun_managed=False)

Add this Redis client to a Tanjun client.

This method will register type dependencies for the resources implemented by it (including tanjun.dependencies.async_cache compatible adapters which will allow Tanjun extensions and standard utility such as converters to be aware of this cache).

The type dependencies this will register depend on which resources are implemented but are as follows for each standard resource implementation:

Parameters:

Raises:

  • RuntimeError

    If this is called in an environment without Tanjun.

all_indexes #

all_indexes()

Get a set of all the Redis client indexes this is using.

Note

This accounts for index overrides.

Returns:

  • MutableSet[ResourceIndex | int]

    A set of all the Redis client indexes this is using.

all_intents classmethod #

all_intents()

The intents required for a client to be sufficient event managed.

If not all these intents are present in the linked event manager then this client won't be able to reliably fill and manage the linked redis database(s).

dump #

dump(data)

Serialize a dict object representation into the form to be stored.

Parameters:

  • data (_ObjectT) –

    The dict object to serialize.

Returns:

  • bytes

    The object serialized as bytes.

get_index_override #

get_index_override(index)

Get the override set for an index.

Parameters:

Returns:

  • int | None

    The found override if set, else None.

load #

load(data)

Deserialize a bytes representation to a dict object.

Parameters:

  • data (bytes) –

    The bytes representation from the database to a dict object.

Returns:

  • dict[str, Any]

    The deserialized dict object.

with_index_override #

with_index_override(index, /, *, override=None)

Add an index override.

Parameters:

  • index (ResourceIndex) –

    The index to override.

  • override (Optional[int], default: None ) –

    The override to set.

    If this is left at None then any previous override is unset. This will decide which Redis database is targeted for a resource.

with_invite_expire #

with_invite_expire(expire)

Set the default expire time for invite entries added with this client.

Parameters:

  • expire (Optional[ExpireT]) –

    The default expire time to add for invites in this cache or None to set back to the default behaviour. This may either be the number of seconds as an int or float (where millisecond precision is supported) or a timedelta.

Returns:

  • Self

    The client this is being called on to enable chained calls.

MemberCache #

Bases: ResourceClient, MemberCache

Redis implementation of sake.abc.MemberCache.

app property #

app

The Hikari client this resource client is tied to.

This is used to build models with a app attribute.

config property #

config

This client's settings.

default_expire property #

default_expire

The default expire time used for fields with no actual lifetime.

If this is None then these cases will have no set expire after.

event_manager property #

event_manager

The event manager this resource client is using for managing state.

__init__ #

__init__(address, app, event_manager=None, *, config=None, default_expire=DEFAULT_SLOW_EXPIRE, event_managed=False, password=None, max_connections_per_db=5, dumps=lambda obj: json.dumps(obj).encode(), loads=json.loads)

Initialise a resource client.

Parameters:

  • app (Union[RESTAware, RESTClient]) –

    The Hikari app or REST client all the models returned by this client should be bound to.

  • address (str) –

    The address to use to connect to the Redis backend server this resource is linked to.

    E.g: - "redis://[[username]:[password]]@localhost:6379" - "rediss://[[username]:[password]]@localhost:6379" - "unix://[[username]:[password]]@/path/to/socket.sock"

    Three URL schemes are supported: - redis://: creates a TCP socket connection. See more at: https://www.iana.org/assignments/uri-schemes/prov/redis - rediss://: creates a SSL wrapped TCP socket connection. See more at: https://www.iana.org/assignments/uri-schemes/prov/rediss - unix://: creates a Unix Domain Socket connection.

  • event_manager (Optional[EventManager], default: None ) –

    The event manager to bind this resource client to.

    If provided then this client will automatically manage resources based on received gateway events.

  • event_managed (bool, default: False ) –

    Whether the client should be started and stopped based on the attached event_manager's lifetime events.

  • password (Optional[str], default: None ) –

    The password to use to connect to the backend Redis server.

Raises:

  • ValueError

    When event_managed is True and event_manager wasn't passed.

add_to_tanjun #

add_to_tanjun(client, /, *, trust_get_for=None, tanjun_managed=False)

Add this Redis client to a Tanjun client.

This method will register type dependencies for the resources implemented by it (including tanjun.dependencies.async_cache compatible adapters which will allow Tanjun extensions and standard utility such as converters to be aware of this cache).

The type dependencies this will register depend on which resources are implemented but are as follows for each standard resource implementation:

Parameters:

Raises:

  • RuntimeError

    If this is called in an environment without Tanjun.

all_indexes #

all_indexes()

Get a set of all the Redis client indexes this is using.

Note

This accounts for index overrides.

Returns:

  • MutableSet[ResourceIndex | int]

    A set of all the Redis client indexes this is using.

all_intents classmethod #

all_intents()

The intents required for a client to be sufficient event managed.

If not all these intents are present in the linked event manager then this client won't be able to reliably fill and manage the linked redis database(s).

dump #

dump(data)

Serialize a dict object representation into the form to be stored.

Parameters:

  • data (_ObjectT) –

    The dict object to serialize.

Returns:

  • bytes

    The object serialized as bytes.

get_index_override #

get_index_override(index)

Get the override set for an index.

Parameters:

Returns:

  • int | None

    The found override if set, else None.

load #

load(data)

Deserialize a bytes representation to a dict object.

Parameters:

  • data (bytes) –

    The bytes representation from the database to a dict object.

Returns:

  • dict[str, Any]

    The deserialized dict object.

with_index_override #

with_index_override(index, /, *, override=None)

Add an index override.

Parameters:

  • index (ResourceIndex) –

    The index to override.

  • override (Optional[int], default: None ) –

    The override to set.

    If this is left at None then any previous override is unset. This will decide which Redis database is targeted for a resource.

MessageCache #

Bases: ResourceClient, MessageCache

Redis implementation of sake.abc.MessageCache.

app property #

app

The Hikari client this resource client is tied to.

This is used to build models with a app attribute.

config property #

config

This client's settings.

default_expire property #

default_expire

The default expire time used for fields with no actual lifetime.

If this is None then these cases will have no set expire after.

event_manager property #

event_manager

The event manager this resource client is using for managing state.

__init__ #

__init__(address, app, event_manager=None, *, config=None, default_expire=DEFAULT_SLOW_EXPIRE, event_managed=False, password=None, max_connections_per_db=5, dumps=lambda obj: json.dumps(obj).encode(), loads=json.loads)

Initialise a resource client.

Parameters:

  • app (Union[RESTAware, RESTClient]) –

    The Hikari app or REST client all the models returned by this client should be bound to.

  • address (str) –

    The address to use to connect to the Redis backend server this resource is linked to.

    E.g: - "redis://[[username]:[password]]@localhost:6379" - "rediss://[[username]:[password]]@localhost:6379" - "unix://[[username]:[password]]@/path/to/socket.sock"

    Three URL schemes are supported: - redis://: creates a TCP socket connection. See more at: https://www.iana.org/assignments/uri-schemes/prov/redis - rediss://: creates a SSL wrapped TCP socket connection. See more at: https://www.iana.org/assignments/uri-schemes/prov/rediss - unix://: creates a Unix Domain Socket connection.

  • event_manager (Optional[EventManager], default: None ) –

    The event manager to bind this resource client to.

    If provided then this client will automatically manage resources based on received gateway events.

  • event_managed (bool, default: False ) –

    Whether the client should be started and stopped based on the attached event_manager's lifetime events.

  • password (Optional[str], default: None ) –

    The password to use to connect to the backend Redis server.

Raises:

  • ValueError

    When event_managed is True and event_manager wasn't passed.

add_to_tanjun #

add_to_tanjun(client, /, *, trust_get_for=None, tanjun_managed=False)

Add this Redis client to a Tanjun client.

This method will register type dependencies for the resources implemented by it (including tanjun.dependencies.async_cache compatible adapters which will allow Tanjun extensions and standard utility such as converters to be aware of this cache).

The type dependencies this will register depend on which resources are implemented but are as follows for each standard resource implementation:

Parameters:

Raises:

  • RuntimeError

    If this is called in an environment without Tanjun.

all_indexes #

all_indexes()

Get a set of all the Redis client indexes this is using.

Note

This accounts for index overrides.

Returns:

  • MutableSet[ResourceIndex | int]

    A set of all the Redis client indexes this is using.

all_intents classmethod #

all_intents()

The intents required for a client to be sufficient event managed.

If not all these intents are present in the linked event manager then this client won't be able to reliably fill and manage the linked redis database(s).

dump #

dump(data)

Serialize a dict object representation into the form to be stored.

Parameters:

  • data (_ObjectT) –

    The dict object to serialize.

Returns:

  • bytes

    The object serialized as bytes.

get_index_override #

get_index_override(index)

Get the override set for an index.

Parameters:

Returns:

  • int | None

    The found override if set, else None.

load #

load(data)

Deserialize a bytes representation to a dict object.

Parameters:

  • data (bytes) –

    The bytes representation from the database to a dict object.

Returns:

  • dict[str, Any]

    The deserialized dict object.

with_index_override #

with_index_override(index, /, *, override=None)

Add an index override.

Parameters:

  • index (ResourceIndex) –

    The index to override.

  • override (Optional[int], default: None ) –

    The override to set.

    If this is left at None then any previous override is unset. This will decide which Redis database is targeted for a resource.

with_message_expire #

with_message_expire(expire)

Set the default expire time for message entries added with this client.

Parameters:

  • expire (Optional[ExpireT]) –

    The default expire time to add for messages in this cache or None to set back to the default behaviour. This may either be the number of seconds as an int or float (where millisecond precision is supported) or a timedelta.

Returns:

  • Self

    The client this is being called on to enable chained calls.

PresenceCache #

Bases: ResourceClient, PresenceCache

Redis implementation of sake.abc.PresenceCache.

app property #

app

The Hikari client this resource client is tied to.

This is used to build models with a app attribute.

config property #

config

This client's settings.

default_expire property #

default_expire

The default expire time used for fields with no actual lifetime.

If this is None then these cases will have no set expire after.

event_manager property #

event_manager

The event manager this resource client is using for managing state.

__init__ #

__init__(address, app, event_manager=None, *, config=None, default_expire=DEFAULT_SLOW_EXPIRE, event_managed=False, password=None, max_connections_per_db=5, dumps=lambda obj: json.dumps(obj).encode(), loads=json.loads)

Initialise a resource client.

Parameters:

  • app (Union[RESTAware, RESTClient]) –

    The Hikari app or REST client all the models returned by this client should be bound to.

  • address (str) –

    The address to use to connect to the Redis backend server this resource is linked to.

    E.g: - "redis://[[username]:[password]]@localhost:6379" - "rediss://[[username]:[password]]@localhost:6379" - "unix://[[username]:[password]]@/path/to/socket.sock"

    Three URL schemes are supported: - redis://: creates a TCP socket connection. See more at: https://www.iana.org/assignments/uri-schemes/prov/redis - rediss://: creates a SSL wrapped TCP socket connection. See more at: https://www.iana.org/assignments/uri-schemes/prov/rediss - unix://: creates a Unix Domain Socket connection.

  • event_manager (Optional[EventManager], default: None ) –

    The event manager to bind this resource client to.

    If provided then this client will automatically manage resources based on received gateway events.

  • event_managed (bool, default: False ) –

    Whether the client should be started and stopped based on the attached event_manager's lifetime events.

  • password (Optional[str], default: None ) –

    The password to use to connect to the backend Redis server.

Raises:

  • ValueError

    When event_managed is True and event_manager wasn't passed.

add_to_tanjun #

add_to_tanjun(client, /, *, trust_get_for=None, tanjun_managed=False)

Add this Redis client to a Tanjun client.

This method will register type dependencies for the resources implemented by it (including tanjun.dependencies.async_cache compatible adapters which will allow Tanjun extensions and standard utility such as converters to be aware of this cache).

The type dependencies this will register depend on which resources are implemented but are as follows for each standard resource implementation:

Parameters:

Raises:

  • RuntimeError

    If this is called in an environment without Tanjun.

all_indexes #

all_indexes()

Get a set of all the Redis client indexes this is using.

Note

This accounts for index overrides.

Returns:

  • MutableSet[ResourceIndex | int]

    A set of all the Redis client indexes this is using.

all_intents classmethod #

all_intents()

The intents required for a client to be sufficient event managed.

If not all these intents are present in the linked event manager then this client won't be able to reliably fill and manage the linked redis database(s).

dump #

dump(data)

Serialize a dict object representation into the form to be stored.

Parameters:

  • data (_ObjectT) –

    The dict object to serialize.

Returns:

  • bytes

    The object serialized as bytes.

get_index_override #

get_index_override(index)

Get the override set for an index.

Parameters:

Returns:

  • int | None

    The found override if set, else None.

load #

load(data)

Deserialize a bytes representation to a dict object.

Parameters:

  • data (bytes) –

    The bytes representation from the database to a dict object.

Returns:

  • dict[str, Any]

    The deserialized dict object.

with_index_override #

with_index_override(index, /, *, override=None)

Add an index override.

Parameters:

  • index (ResourceIndex) –

    The index to override.

  • override (Optional[int], default: None ) –

    The override to set.

    If this is left at None then any previous override is unset. This will decide which Redis database is targeted for a resource.

RedisCache #

Bases: GuildCache, EmojiCache, GuildChannelCache, InviteCache, MemberCache, MessageCache, PresenceCache, RoleCache, UserCache, VoiceStateCache, Cache

A Redis implementation of all the defined cache resources.

app property #

app

The Hikari client this resource client is tied to.

This is used to build models with a app attribute.

config property #

config

This client's settings.

default_expire property #

default_expire

The default expire time used for fields with no actual lifetime.

If this is None then these cases will have no set expire after.

event_manager property #

event_manager

The event manager this resource client is using for managing state.

__init__ #

__init__(address, app, event_manager=None, *, config=None, default_expire=DEFAULT_SLOW_EXPIRE, event_managed=False, password=None, max_connections_per_db=5, dumps=lambda obj: json.dumps(obj).encode(), loads=json.loads)

Initialise a resource client.

Parameters:

  • app (Union[RESTAware, RESTClient]) –

    The Hikari app or REST client all the models returned by this client should be bound to.

  • address (str) –

    The address to use to connect to the Redis backend server this resource is linked to.

    E.g: - "redis://[[username]:[password]]@localhost:6379" - "rediss://[[username]:[password]]@localhost:6379" - "unix://[[username]:[password]]@/path/to/socket.sock"

    Three URL schemes are supported: - redis://: creates a TCP socket connection. See more at: https://www.iana.org/assignments/uri-schemes/prov/redis - rediss://: creates a SSL wrapped TCP socket connection. See more at: https://www.iana.org/assignments/uri-schemes/prov/rediss - unix://: creates a Unix Domain Socket connection.

  • event_manager (Optional[EventManager], default: None ) –

    The event manager to bind this resource client to.

    If provided then this client will automatically manage resources based on received gateway events.

  • event_managed (bool, default: False ) –

    Whether the client should be started and stopped based on the attached event_manager's lifetime events.

  • password (Optional[str], default: None ) –

    The password to use to connect to the backend Redis server.

Raises:

  • ValueError

    When event_managed is True and event_manager wasn't passed.

add_to_tanjun #

add_to_tanjun(client, /, *, trust_get_for=None, tanjun_managed=False)

Add this Redis client to a Tanjun client.

This method will register type dependencies for the resources implemented by it (including tanjun.dependencies.async_cache compatible adapters which will allow Tanjun extensions and standard utility such as converters to be aware of this cache).

The type dependencies this will register depend on which resources are implemented but are as follows for each standard resource implementation:

Parameters:

Raises:

  • RuntimeError

    If this is called in an environment without Tanjun.

all_indexes #

all_indexes()

Get a set of all the Redis client indexes this is using.

Note

This accounts for index overrides.

Returns:

  • MutableSet[ResourceIndex | int]

    A set of all the Redis client indexes this is using.

all_intents classmethod #

all_intents()

The intents required for a client to be sufficient event managed.

If not all these intents are present in the linked event manager then this client won't be able to reliably fill and manage the linked redis database(s).

dump #

dump(data)

Serialize a dict object representation into the form to be stored.

Parameters:

  • data (_ObjectT) –

    The dict object to serialize.

Returns:

  • bytes

    The object serialized as bytes.

get_index_override #

get_index_override(index)

Get the override set for an index.

Parameters:

Returns:

  • int | None

    The found override if set, else None.

load #

load(data)

Deserialize a bytes representation to a dict object.

Parameters:

  • data (bytes) –

    The bytes representation from the database to a dict object.

Returns:

  • dict[str, Any]

    The deserialized dict object.

with_index_override #

with_index_override(index, /, *, override=None)

Add an index override.

Parameters:

  • index (ResourceIndex) –

    The index to override.

  • override (Optional[int], default: None ) –

    The override to set.

    If this is left at None then any previous override is unset. This will decide which Redis database is targeted for a resource.

with_invite_expire #

with_invite_expire(expire)

Set the default expire time for invite entries added with this client.

Parameters:

  • expire (Optional[ExpireT]) –

    The default expire time to add for invites in this cache or None to set back to the default behaviour. This may either be the number of seconds as an int or float (where millisecond precision is supported) or a timedelta.

Returns:

  • Self

    The client this is being called on to enable chained calls.

with_message_expire #

with_message_expire(expire)

Set the default expire time for message entries added with this client.

Parameters:

  • expire (Optional[ExpireT]) –

    The default expire time to add for messages in this cache or None to set back to the default behaviour. This may either be the number of seconds as an int or float (where millisecond precision is supported) or a timedelta.

Returns:

  • Self

    The client this is being called on to enable chained calls.

with_user_expire #

with_user_expire(expire)

Set the default expire time for user entries added with this client.

Parameters:

  • expire (Optional[ExpireT]) –

    The default expire time to add for users in this cache or None to set back to the default behaviour. This may either be the number of seconds as an int or float (where millisecond precision is supported) or a timedelta.

Returns:

  • Self

    The client this is being called on to enable chained calls.

ResourceClient #

Bases: Resource, ABC

A base client which all resources in this implementation will implement.

Note

This cannot be initialised by itself and is useless alone.

app property #

app

The Hikari client this resource client is tied to.

This is used to build models with a app attribute.

config property #

config

This client's settings.

default_expire property #

default_expire

The default expire time used for fields with no actual lifetime.

If this is None then these cases will have no set expire after.

event_manager property #

event_manager

The event manager this resource client is using for managing state.

__init__ #

__init__(address, app, event_manager=None, *, config=None, default_expire=DEFAULT_SLOW_EXPIRE, event_managed=False, password=None, max_connections_per_db=5, dumps=lambda obj: json.dumps(obj).encode(), loads=json.loads)

Initialise a resource client.

Parameters:

  • app (Union[RESTAware, RESTClient]) –

    The Hikari app or REST client all the models returned by this client should be bound to.

  • address (str) –

    The address to use to connect to the Redis backend server this resource is linked to.

    E.g: - "redis://[[username]:[password]]@localhost:6379" - "rediss://[[username]:[password]]@localhost:6379" - "unix://[[username]:[password]]@/path/to/socket.sock"

    Three URL schemes are supported: - redis://: creates a TCP socket connection. See more at: https://www.iana.org/assignments/uri-schemes/prov/redis - rediss://: creates a SSL wrapped TCP socket connection. See more at: https://www.iana.org/assignments/uri-schemes/prov/rediss - unix://: creates a Unix Domain Socket connection.

  • event_manager (Optional[EventManager], default: None ) –

    The event manager to bind this resource client to.

    If provided then this client will automatically manage resources based on received gateway events.

  • event_managed (bool, default: False ) –

    Whether the client should be started and stopped based on the attached event_manager's lifetime events.

  • password (Optional[str], default: None ) –

    The password to use to connect to the backend Redis server.

Raises:

  • ValueError

    When event_managed is True and event_manager wasn't passed.

add_to_tanjun #

add_to_tanjun(client, /, *, trust_get_for=None, tanjun_managed=False)

Add this Redis client to a Tanjun client.

This method will register type dependencies for the resources implemented by it (including tanjun.dependencies.async_cache compatible adapters which will allow Tanjun extensions and standard utility such as converters to be aware of this cache).

The type dependencies this will register depend on which resources are implemented but are as follows for each standard resource implementation:

Parameters:

Raises:

  • RuntimeError

    If this is called in an environment without Tanjun.

all_indexes #

all_indexes()

Get a set of all the Redis client indexes this is using.

Note

This accounts for index overrides.

Returns:

  • MutableSet[ResourceIndex | int]

    A set of all the Redis client indexes this is using.

all_intents classmethod #

all_intents()

The intents required for a client to be sufficient event managed.

If not all these intents are present in the linked event manager then this client won't be able to reliably fill and manage the linked redis database(s).

dump #

dump(data)

Serialize a dict object representation into the form to be stored.

Parameters:

  • data (_ObjectT) –

    The dict object to serialize.

Returns:

  • bytes

    The object serialized as bytes.

get_index_override #

get_index_override(index)

Get the override set for an index.

Parameters:

Returns:

  • int | None

    The found override if set, else None.

index abstractmethod classmethod #

index()

The index for the resource which this class is linked to.

Note

This should be called on specific base classes and will not be accurate after inheritance.

Warning

This doesn't account for overrides.

Returns:

  • Sequence[ResourceIndex]

    The index of the resource this class is linked to.

intents abstractmethod classmethod #

intents()

The intents the resource requires to function properly.

Note

This should be called on specific base classes and will not be accurate after inheritance.

Returns:

  • Intents

    The intents the resource requires to function properly.

load #

load(data)

Deserialize a bytes representation to a dict object.

Parameters:

  • data (bytes) –

    The bytes representation from the database to a dict object.

Returns:

  • dict[str, Any]

    The deserialized dict object.

with_index_override #

with_index_override(index, /, *, override=None)

Add an index override.

Parameters:

  • index (ResourceIndex) –

    The index to override.

  • override (Optional[int], default: None ) –

    The override to set.

    If this is left at None then any previous override is unset. This will decide which Redis database is targeted for a resource.

ResourceIndex #

Bases: IntEnum

An enum of the indexes used to map cache resources to their redis databases.

RoleCache #

Bases: _Reference, RoleCache

Redis implementation of sake.abc.RoleCache.

app property #

app

The Hikari client this resource client is tied to.

This is used to build models with a app attribute.

config property #

config

This client's settings.

default_expire property #

default_expire

The default expire time used for fields with no actual lifetime.

If this is None then these cases will have no set expire after.

event_manager property #

event_manager

The event manager this resource client is using for managing state.

__init__ #

__init__(address, app, event_manager=None, *, config=None, default_expire=DEFAULT_SLOW_EXPIRE, event_managed=False, password=None, max_connections_per_db=5, dumps=lambda obj: json.dumps(obj).encode(), loads=json.loads)

Initialise a resource client.

Parameters:

  • app (Union[RESTAware, RESTClient]) –

    The Hikari app or REST client all the models returned by this client should be bound to.

  • address (str) –

    The address to use to connect to the Redis backend server this resource is linked to.

    E.g: - "redis://[[username]:[password]]@localhost:6379" - "rediss://[[username]:[password]]@localhost:6379" - "unix://[[username]:[password]]@/path/to/socket.sock"

    Three URL schemes are supported: - redis://: creates a TCP socket connection. See more at: https://www.iana.org/assignments/uri-schemes/prov/redis - rediss://: creates a SSL wrapped TCP socket connection. See more at: https://www.iana.org/assignments/uri-schemes/prov/rediss - unix://: creates a Unix Domain Socket connection.

  • event_manager (Optional[EventManager], default: None ) –

    The event manager to bind this resource client to.

    If provided then this client will automatically manage resources based on received gateway events.

  • event_managed (bool, default: False ) –

    Whether the client should be started and stopped based on the attached event_manager's lifetime events.

  • password (Optional[str], default: None ) –

    The password to use to connect to the backend Redis server.

Raises:

  • ValueError

    When event_managed is True and event_manager wasn't passed.

add_to_tanjun #

add_to_tanjun(client, /, *, trust_get_for=None, tanjun_managed=False)

Add this Redis client to a Tanjun client.

This method will register type dependencies for the resources implemented by it (including tanjun.dependencies.async_cache compatible adapters which will allow Tanjun extensions and standard utility such as converters to be aware of this cache).

The type dependencies this will register depend on which resources are implemented but are as follows for each standard resource implementation:

Parameters:

Raises:

  • RuntimeError

    If this is called in an environment without Tanjun.

all_indexes #

all_indexes()

Get a set of all the Redis client indexes this is using.

Note

This accounts for index overrides.

Returns:

  • MutableSet[ResourceIndex | int]

    A set of all the Redis client indexes this is using.

all_intents classmethod #

all_intents()

The intents required for a client to be sufficient event managed.

If not all these intents are present in the linked event manager then this client won't be able to reliably fill and manage the linked redis database(s).

dump #

dump(data)

Serialize a dict object representation into the form to be stored.

Parameters:

  • data (_ObjectT) –

    The dict object to serialize.

Returns:

  • bytes

    The object serialized as bytes.

get_index_override #

get_index_override(index)

Get the override set for an index.

Parameters:

Returns:

  • int | None

    The found override if set, else None.

load #

load(data)

Deserialize a bytes representation to a dict object.

Parameters:

  • data (bytes) –

    The bytes representation from the database to a dict object.

Returns:

  • dict[str, Any]

    The deserialized dict object.

with_index_override #

with_index_override(index, /, *, override=None)

Add an index override.

Parameters:

  • index (ResourceIndex) –

    The index to override.

  • override (Optional[int], default: None ) –

    The override to set.

    If this is left at None then any previous override is unset. This will decide which Redis database is targeted for a resource.

UserCache #

Bases: _MeCache, UserCache

Redis implementation of sake.abc.UserCache.

app property #

app

The Hikari client this resource client is tied to.

This is used to build models with a app attribute.

config property #

config

This client's settings.

default_expire property #

default_expire

The default expire time used for fields with no actual lifetime.

If this is None then these cases will have no set expire after.

event_manager property #

event_manager

The event manager this resource client is using for managing state.

__init__ #

__init__(address, app, event_manager=None, *, config=None, default_expire=DEFAULT_SLOW_EXPIRE, event_managed=False, password=None, max_connections_per_db=5, dumps=lambda obj: json.dumps(obj).encode(), loads=json.loads)

Initialise a resource client.

Parameters:

  • app (Union[RESTAware, RESTClient]) –

    The Hikari app or REST client all the models returned by this client should be bound to.

  • address (str) –

    The address to use to connect to the Redis backend server this resource is linked to.

    E.g: - "redis://[[username]:[password]]@localhost:6379" - "rediss://[[username]:[password]]@localhost:6379" - "unix://[[username]:[password]]@/path/to/socket.sock"

    Three URL schemes are supported: - redis://: creates a TCP socket connection. See more at: https://www.iana.org/assignments/uri-schemes/prov/redis - rediss://: creates a SSL wrapped TCP socket connection. See more at: https://www.iana.org/assignments/uri-schemes/prov/rediss - unix://: creates a Unix Domain Socket connection.

  • event_manager (Optional[EventManager], default: None ) –

    The event manager to bind this resource client to.

    If provided then this client will automatically manage resources based on received gateway events.

  • event_managed (bool, default: False ) –

    Whether the client should be started and stopped based on the attached event_manager's lifetime events.

  • password (Optional[str], default: None ) –

    The password to use to connect to the backend Redis server.

Raises:

  • ValueError

    When event_managed is True and event_manager wasn't passed.

add_to_tanjun #

add_to_tanjun(client, /, *, trust_get_for=None, tanjun_managed=False)

Add this Redis client to a Tanjun client.

This method will register type dependencies for the resources implemented by it (including tanjun.dependencies.async_cache compatible adapters which will allow Tanjun extensions and standard utility such as converters to be aware of this cache).

The type dependencies this will register depend on which resources are implemented but are as follows for each standard resource implementation:

Parameters:

Raises:

  • RuntimeError

    If this is called in an environment without Tanjun.

all_indexes #

all_indexes()

Get a set of all the Redis client indexes this is using.

Note

This accounts for index overrides.

Returns:

  • MutableSet[ResourceIndex | int]

    A set of all the Redis client indexes this is using.

all_intents classmethod #

all_intents()

The intents required for a client to be sufficient event managed.

If not all these intents are present in the linked event manager then this client won't be able to reliably fill and manage the linked redis database(s).

dump #

dump(data)

Serialize a dict object representation into the form to be stored.

Parameters:

  • data (_ObjectT) –

    The dict object to serialize.

Returns:

  • bytes

    The object serialized as bytes.

get_index_override #

get_index_override(index)

Get the override set for an index.

Parameters:

Returns:

  • int | None

    The found override if set, else None.

load #

load(data)

Deserialize a bytes representation to a dict object.

Parameters:

  • data (bytes) –

    The bytes representation from the database to a dict object.

Returns:

  • dict[str, Any]

    The deserialized dict object.

with_index_override #

with_index_override(index, /, *, override=None)

Add an index override.

Parameters:

  • index (ResourceIndex) –

    The index to override.

  • override (Optional[int], default: None ) –

    The override to set.

    If this is left at None then any previous override is unset. This will decide which Redis database is targeted for a resource.

with_user_expire #

with_user_expire(expire)

Set the default expire time for user entries added with this client.

Parameters:

  • expire (Optional[ExpireT]) –

    The default expire time to add for users in this cache or None to set back to the default behaviour. This may either be the number of seconds as an int or float (where millisecond precision is supported) or a timedelta.

Returns:

  • Self

    The client this is being called on to enable chained calls.

VoiceStateCache #

Bases: _Reference, VoiceStateCache

Redis implementation of sake.abc.VoiceStateCache.

app property #

app

The Hikari client this resource client is tied to.

This is used to build models with a app attribute.

config property #

config

This client's settings.

default_expire property #

default_expire

The default expire time used for fields with no actual lifetime.

If this is None then these cases will have no set expire after.

event_manager property #

event_manager

The event manager this resource client is using for managing state.

__init__ #

__init__(address, app, event_manager=None, *, config=None, default_expire=DEFAULT_SLOW_EXPIRE, event_managed=False, password=None, max_connections_per_db=5, dumps=lambda obj: json.dumps(obj).encode(), loads=json.loads)

Initialise a resource client.

Parameters:

  • app (Union[RESTAware, RESTClient]) –

    The Hikari app or REST client all the models returned by this client should be bound to.

  • address (str) –

    The address to use to connect to the Redis backend server this resource is linked to.

    E.g: - "redis://[[username]:[password]]@localhost:6379" - "rediss://[[username]:[password]]@localhost:6379" - "unix://[[username]:[password]]@/path/to/socket.sock"

    Three URL schemes are supported: - redis://: creates a TCP socket connection. See more at: https://www.iana.org/assignments/uri-schemes/prov/redis - rediss://: creates a SSL wrapped TCP socket connection. See more at: https://www.iana.org/assignments/uri-schemes/prov/rediss - unix://: creates a Unix Domain Socket connection.

  • event_manager (Optional[EventManager], default: None ) –

    The event manager to bind this resource client to.

    If provided then this client will automatically manage resources based on received gateway events.

  • event_managed (bool, default: False ) –

    Whether the client should be started and stopped based on the attached event_manager's lifetime events.

  • password (Optional[str], default: None ) –

    The password to use to connect to the backend Redis server.

Raises:

  • ValueError

    When event_managed is True and event_manager wasn't passed.

add_to_tanjun #

add_to_tanjun(client, /, *, trust_get_for=None, tanjun_managed=False)

Add this Redis client to a Tanjun client.

This method will register type dependencies for the resources implemented by it (including tanjun.dependencies.async_cache compatible adapters which will allow Tanjun extensions and standard utility such as converters to be aware of this cache).

The type dependencies this will register depend on which resources are implemented but are as follows for each standard resource implementation:

Parameters:

Raises:

  • RuntimeError

    If this is called in an environment without Tanjun.

all_indexes #

all_indexes()

Get a set of all the Redis client indexes this is using.

Note

This accounts for index overrides.

Returns:

  • MutableSet[ResourceIndex | int]

    A set of all the Redis client indexes this is using.

all_intents classmethod #

all_intents()

The intents required for a client to be sufficient event managed.

If not all these intents are present in the linked event manager then this client won't be able to reliably fill and manage the linked redis database(s).

dump #

dump(data)

Serialize a dict object representation into the form to be stored.

Parameters:

  • data (_ObjectT) –

    The dict object to serialize.

Returns:

  • bytes

    The object serialized as bytes.

get_index_override #

get_index_override(index)

Get the override set for an index.

Parameters:

Returns:

  • int | None

    The found override if set, else None.

load #

load(data)

Deserialize a bytes representation to a dict object.

Parameters:

  • data (bytes) –

    The bytes representation from the database to a dict object.

Returns:

  • dict[str, Any]

    The deserialized dict object.

with_index_override #

with_index_override(index, /, *, override=None)

Add an index override.

Parameters:

  • index (ResourceIndex) –

    The index to override.

  • override (Optional[int], default: None ) –

    The override to set.

    If this is left at None then any previous override is unset. This will decide which Redis database is targeted for a resource.