fontcolor_theme
package

API @deepkit/broker-redis

npm install @deepkit/broker-redis

Stellt eine Redis-basierte Implementierung des Deepkit Brokers bereit. Dabei wird ioredis unter der Haube verwendet.

Dieser Adapter implementiert nicht den Queue-Adapter des Deepkit Brokers.

import { BrokerKeyValue, BrokerBus } from '@deepkit/broker';
import { BrokerRedisAdapter } from '@deepkit/broker-redis';
import { ConsoleLogger } from '@deepkit/logger';

const adapter = new RedisBrokerAdapter({
    preifx: 'myapp:',
    host: 'localhost',
    port: 6379,
    // Optional, falls der Redis-Server eine Authentifizierung erfordert
    // db: 0, // Optional, um eine andere Redis-Datenbank anzugeben
}, new ConsoleLogger());

const keyValye = new BrokerKeyValue(adapter);
const bus = new BrokerBus(adapter);
// ...

Classes

RedisBrokerAdapter [source]
export class RedisBrokerAdapter implements BrokerAdapterBus, BrokerAdapterKeyValue, BrokerAdapterCache, BrokerAdapterLock {
    constructor(private config: RedisBrokerAdapterOptions, public logger: Logger);
    async isLocked(id: string): Promise<boolean>;
    async lock(id: string, options: BrokerTimeOptionsResolved): Promise<Release | undefined>;
    async tryLock(id: string, options: BrokerTimeOptionsResolved): Promise<Release | undefined>;
    async disconnect(): Promise<void>;
    async publish(name: string, message: any, type: Type): Promise<void>;
    async subscribe(name: string, callback: (message: any) => void, type: Type): Promise<Release>;
    async get(key: string, type: Type): Promise<any>;
    async increment(key: string, value: number): Promise<number>;
    async remove(key: string): Promise<any>;
    async set(key: string, value: any, options: BrokerKeyValueOptionsResolved, type: Type): Promise<any>;
    async getCache(key: string, type: Type): Promise<{
        value: any;
        ttl: number;
    } | undefined>;
    async setCache(key: string, value: any, options: BrokerCacheItemOptionsResolved, type: Type): Promise<void>;
    async getCacheMeta(key: string): Promise<{
        ttl: number;
    } | undefined>;
    async invalidateCache(key: string): Promise<void>;
    onInvalidateCache(callback: (key: string) => void): void;
}

Types

RedisBrokerAdapterOptions [source]
type RedisBrokerAdapterOptions = RedisOptions & {
    prefix?: string; // optional prefix for all keys
}

English中文 (Chinese)한국어 (Korean)日本語 (Japanese)Deutsch (German)