Please Note, the Queue is always "cached" on the client side, which means it's still quite fast, however, the speed of "saving and syncing" depends on the StoreManager.
Here is a List of External Stores I'd recommend:
(Redis Remake, but for bigger scale and it's quite faster than redis)
(Good old Key-Value Database)
(old alternative to Redis)
via (SQL Database for high work-flow)
(New SQL Database)
Overview
Parameter
Type
Required
Description
get
✓
set
✓
delete
✓
stringify
✓
parse
✓
The interface `QueueStoreManager` declares, what methods your custom QueueStore requires!
export interface QueueStoreManager extends Record<string, any>{
/** @async get a Value (MUST RETURN UNPARSED!) */
get: (guildId: unknown) => Promise<any>;
/** @async Set a value inside a guildId (MUST BE UNPARSED) */
set: (guildId: unknown, value: unknown) => Promise<any>;
/** @async Delete a Database Value based of it's guildId */
delete: (guildId: unknown) => Promise<any>;
/** @async Transform the value(s) inside of the QueueStoreManager (IF YOU DON'T NEED PARSING/STRINGIFY, then just return the value) */
stringify: (value: unknown) => Promise<any>;
/** @async Parse the saved value back to the Queue (IF YOU DON'T NEED PARSING/STRINGIFY, then just return the value) */
parse: (value: unknown) => Promise<Partial<StoredQueue>>;
}
Examples:
Example Queue Store Manager:
This is also the Default Queue Store, which you can import from lavalink-client!
export class myCustomStore implements QueueStoreManager {
private redis:RedisClientType;
constructor(redisClient:RedisClientType) {
this.redis = redisClient;
}
async get(guildId): Promise<any> {
return await this.redis.get(this.id(guildId));
}
async set(guildId, stringifiedQueueData): Promise<any> {
// await this.delete(guildId); // redis requires you to delete it first;
return await this.redis.set(this.id(guildId), stringifiedQueueData);
}
async delete(guildId): Promise<any> {
return await this.redis.del(this.id(guildId));
}
async parse(stringifiedQueueData): Promise<Partial<StoredQueue>> {
return JSON.parse(stringifiedQueueData);
}
async stringify(parsedQueueData): Promise<any> {
return JSON.stringify(parsedQueueData);
}
// you can add more utils if you need to...
private id(guildId) {
return `lavalinkqueue_${guildId}`; // transform the id
}
}