fontcolor_theme
package

API @deepkit/broker-redis

npm install @deepkit/broker-redis

Deepkit Broker의 Redis 기반 구현을 제공합니다. 내부적으로 ioredis를 사용합니다.

이 adapter는 Deepkit Broker의 queue adapter를 구현하지 않습니다.

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,
    // password: 'your-password', // 선택 사항, Redis 서버에서 인증이 필요한 경우
    // db: 0, // 선택 사항, 다른 Redis 데이터베이스를 지정하려는 경우
}, 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)