QueueStorageAdapter
Class representing a storage manager.
Signature
export declare class QueueStorageAdapter<T extends QueueJSON = QueueJSON>JSDoc
Examples
class MyStorageManager extends QueueStorageAdapter {};
const storage = new MyStorageManager();
storage.set("key", "value");
const value = await storage.get("key");
console.log(value); // "value"@abstract@classQueueStorageAdapter
Properties
namespace: string;The namespace of the storage.
Examples
console.log(storage.namespace); // "hoshimiqueue"@type{string}@default"hoshimiqueue"
Methods
abstract get(key: string): Awaitable<T | undefined>;Get the value using the key.
Parameters
key- The key to get the value from.
Returns
The value of the key.
Examples
const value = await storage.get("key");
console.log(value); // "value"abstract set(key: string, value: T): Awaitable<void>;Set the value using the key.
Parameters
key- The key to set the value to.
value- The value to set.
Returns
Did you know this can be async?
Examples
await storage.set("key", "value");abstract delete(key: string): Awaitable<boolean>;Delete the value using the key.
Parameters
key- The key to delete the value from.
Returns
Returns true if the key was deleted.
Examples
const success = await storage.delete("key");
console.log(success); // trueabstract clear(): Awaitable<void>;Clear the storage.
Returns
Scary, right?
Examples
await storage.clear();abstract has(key: string): Awaitable<boolean>;Check if the storage has the key.
Parameters
key- The key to check.
Returns
Return true if the key exists.
Examples
const exists = await storage.has("key");
console.log(exists); // trueabstract parse(value: unknown): Awaitable<T>;Parse the value.
Parameters
value- The value to parse.
Returns
The parsed value.
Examples
const parsed = await storage.parse("{'key':'value'}");
console.log(parsed); // { key: "value" }abstract stringify<R = string>(value: unknown): Awaitable<R>;Stringify the value.
Parameters
value- The value to stringify.
Returns
The stringified value.
Examples
const stringified = await storage.stringify({ key: "value" });
console.log(stringified); // "{'key':'value'}"buildKey(...parts: RestOrArray<string>): string;Build a key from the given parts.
Parameters
parts- The parts to build the key from.
Returns
The built key.
Examples
const key = storage.buildKey("part1", "part2", "part3");