seyfert
Version:
The most advanced framework for discord bots
69 lines (68 loc) • 2.72 kB
TypeScript
import { LimitedCollection } from '../..';
import { type MakeRequired } from '../../common';
import type { Adapter } from './types';
export interface ResourceLimitedMemoryAdapter {
expire?: number;
limit?: number;
}
export interface LimitedMemoryAdapterOptions<T> {
default?: ResourceLimitedMemoryAdapter;
guild?: ResourceLimitedMemoryAdapter;
user?: ResourceLimitedMemoryAdapter;
ban?: ResourceLimitedMemoryAdapter;
member?: ResourceLimitedMemoryAdapter;
voice_state?: ResourceLimitedMemoryAdapter;
channel?: ResourceLimitedMemoryAdapter;
emoji?: ResourceLimitedMemoryAdapter;
presence?: ResourceLimitedMemoryAdapter;
role?: ResourceLimitedMemoryAdapter;
stage_instance?: ResourceLimitedMemoryAdapter;
sticker?: ResourceLimitedMemoryAdapter;
overwrite?: ResourceLimitedMemoryAdapter;
message?: ResourceLimitedMemoryAdapter;
encode?(data: any): T;
decode?(data: T): unknown;
}
export declare class LimitedMemoryAdapter<T> implements Adapter {
isAsync: boolean;
readonly storage: Map<string, LimitedCollection<string, T>>;
readonly relationships: Map<string, Map<string, Set<string>>>;
readonly keyToStorage: Map<string, LimitedCollection<string, T>>;
options: MakeRequired<LimitedMemoryAdapterOptions<T>, 'default' | 'encode' | 'decode'>;
constructor(options?: LimitedMemoryAdapterOptions<T>);
start(): void;
scan(query: string, keys?: false): any[];
scan(query: string, keys: true): string[];
bulkGet(keys: string[]): unknown[];
private _getKeyResource;
private _getKeyScope;
private _supportsNamespaceIndex;
private _setIndexedStorage;
private _deleteIndexedStorage;
private _getIndexedStorage;
private _getDerivedNamespace;
private _isResourceNamespace;
private _findNamespaceByStorage;
private _getStorageNamespace;
private _getStorageEntry;
get(key: string): unknown;
private __set;
bulkSet(keys: [string, any][]): void;
set(keys: string, data: any): void;
bulkPatch(keys: [string, any][]): void;
patch(keys: string, data: any): void;
values(to: string): any[];
keys(to: string): string[];
count(to: string): number;
bulkRemove(keys: string[]): void;
remove(key: string): void;
flush(): void;
contains(to: string, keys: string): boolean;
private _getRelationshipData;
private _getRelationshipSet;
getToRelationship(to: string): string[];
bulkAddToRelationShip(data: Record<string, string[]>): void;
addToRelationship(to: string, keys: string | string[]): void;
removeToRelationship(to: string, keys: string | string[]): void;
removeRelationship(to: string | string[]): void;
}