@types/cache-manager-ioredis

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/cache-manager-ioredis

TypeScript definitions for cache-manager-ioredis

ts5.0
ts5.1
ts5.2
ts5.3
ts5.4
ts5.5
ts5.6
ts5.7
ts5.8
ts5.9
ts6.0
latest
Version
2.0.7
Version published
Maintainers
1
Created

Installation

npm install --save @types/cache-manager-ioredis

Summary

This package contains type definitions for cache-manager-ioredis (https://github.com/dabroek/node-cache-manager-ioredis).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/cache-manager-ioredis.

index.d.ts

import { Cache, CacheOptions, CachingConfig, Store } from "cache-manager";
import * as IORedis from "ioredis";

declare const methods: CacheManagerIORedis.RedisStoreConstructor;
export = methods;
export {};

declare module "cache-manager" {
    function caching(IConfig: CacheManagerIORedis.RedisStoreClusterConfig): CacheManagerIORedis.ClusterCache;
    function caching(IConfig: CacheManagerIORedis.RedisStoreSingleNodeConfig): CacheManagerIORedis.SingleNodeCache;
    function caching(IConfig: StoreConfig & CacheOptions): Cache;
}

declare namespace CacheManagerIORedis {
    interface SingleNodeCache extends Cache {
        store: RedisSingleNodeStore;
    }

    interface ClusterCache extends Cache {
        store: RedisClusterStore;
    }

    interface RedisStoreConstructor {
        create:
            | ((...options: RedisStoreSingleNodeConfig[]) => RedisSingleNodeStore)
            | ((...options: RedisStoreClusterConfig[]) => RedisClusterStore);
    }

    type RedisStoreSingleNodeConfig = CachingConfig & IORedis.RedisOptions & {
        store: RedisStoreConstructor;
        max?: number | undefined;
    } & CacheOptions;

    type RedisStoreClusterConfig = CachingConfig & {
        store: RedisStoreConstructor;
        max?: number | undefined;
        clusterConfig: ClusterOptions;
    } & CacheOptions;

    interface RedisStore extends Store {
        getClient(): IORedis.Redis | IORedis.Cluster;
        name: "redis";
        isCacheableValue(value: any): boolean;
        del(...args: any[]): Promise<any>;
        reset(...args: any[]): Promise<any>;
        keys(...args: any[]): Promise<any>;
        ttl(...args: any[]): Promise<any>;
    }

    interface RedisSingleNodeStore extends RedisStore {
        getClient(): IORedis.Redis;
    }

    interface RedisClusterStore extends RedisStore {
        getClient(): IORedis.Cluster;
    }

    interface ClusterOptions {
        nodes: IORedis.ClusterNode[];
        options: IORedis.ClusterOptions;
    }
}

Additional Details

Credits

These definitions were written by Yi Hong.

FAQs

Package last updated on 03 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts