mastercache
Version:
Multi-tier cache module for Node.js. Redis, Upstash, CloudfareKV, File, in-memory and others drivers
82 lines (79 loc) • 2.47 kB
TypeScript
import { RedisOptions, Redis } from 'ioredis';
import { BaseDriver } from './base-driver.js';
import { a as CreateBusDriverResult, b as L2CacheDriver, C as CreateDriverResult } from '../../mastercache-Di19srNZ.js';
import { RedisConfig } from '../types/options/drivers-options.js';
import { BusOptions } from '../types/bus.js';
import '../types/driver.js';
import '../types/provider.js';
import '../types/helpers.js';
import 'typescript-log';
import '../types/options/methods-options.js';
import '../types/options/options.js';
import '../../events-CkqPK7En.js';
import 'knex';
import 'kysely';
import '@aws-sdk/client-dynamodb';
import 'orchid-orm';
import '@boringnode/bus/types/main';
/**
* Create a new bus redis driver. It leverages the Pub/sub capabilities of Redis
* to sending messages between your different processes.
*/
declare function redisBusDriver(options: {
connection: RedisOptions;
} & BusOptions): CreateBusDriverResult;
/**
* Caching driver for Redis
*/
declare class RedisDriver extends BaseDriver implements L2CacheDriver {
#private;
type: "l2";
config: RedisConfig;
constructor(config: RedisConfig);
getConnection(): Redis;
/**
* Returns a new instance of the driver namespaced
*/
namespace(namespace: string): RedisDriver;
/**
* Get a value from the cache
*/
get(key: string): Promise<string | undefined>;
/**
* Get the value of a key and delete it
*
* Returns the value if the key exists, undefined otherwise
*/
pull(key: string): Promise<string | undefined>;
/**
* Put a value in the cache
* Returns true if the value was set, false otherwise
*/
set(key: string, value: string, ttl?: number): Promise<boolean>;
/**
* Check if a key exists in the cache
*/
has(key: string): Promise<boolean>;
/**
* Remove all items from the cache
*/
clear(): Promise<void>;
/**
* Delete a key from the cache
* Returns true if the key was deleted, false otherwise
*/
delete(key: string): Promise<boolean>;
/**
* Delete multiple keys from the cache
*/
deleteMany(keys: string[]): Promise<boolean>;
/**
* Closes the connection to the cache
*/
disconnect(): Promise<void>;
}
/**
* Create a new cache redis driver
*/
declare function redisDriver(options: RedisConfig): CreateDriverResult<RedisDriver>;
export { RedisDriver, redisBusDriver, redisDriver };