README
@soluble/cache-ioredis
@soluble/cache-interop cache adapter for node ioredis driver.
Documentation
About |Cache adapter for node IoRedis client.
Install
$ yarn add @soluble/cache-ioredis ioredis
$ yarn add @types/ioredis --dev
Usage
import { IoRedisCacheAdapter } from '@soluble/cache-ioredis';
const cache = new IoRedisCacheAdapter({
connection: 'redis://:pass@localhost:6379/8',
});
const { data, error } = await cache.getOrSet('key', asyncPromise, {
ttl: 30,
});
if (await cache.has('key')) {
await cache.delete('key');
}
Constructor
Connection
IORedisAdapter connection
param can be a dsn as string, an IORedisConnection,
the native IORedis.RedisOptions connection.
You can use the
getIoRedisOptionsFromDsn
function to initiate a connection with native parameters.import { IoRedisCacheAdapter, getIoRedisOptionsFromDsn } from '@soluble/cache-ioredis'; const dsn = 'redis://localhost:6379/db2'; const cache = new IoRedisCacheAdapter({ connection: getIoRedisOptionsFromDsn(dsn, { // here all io-redis params. connectTimeout: 1, }), });