@soluble/cache-ioredis
TypeScript icon, indicating that this package has built-in type declarations

0.13.11 • Public • Published

Codecov Downloads Codecov Codefactor CodeClimate TechDebt Typings Licence

About | Documentation

Cache adapter for node IoRedis client.

Install

$ yarn add @soluble/cache-ioredis

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,
  }),
});

Sponsors ❤️

If you are enjoying some of my OSS guides or libs for your company, I'd really appreciate a sponsorship, a coffee or a dropped star. That gives me a tasty morning boost and help me to make some of my ideas come true 🙏

Special thanks

Jetbrains logo Jetbrains logo
JetBrains Embie.be

Readme

Keywords

Package Sidebar

Install

npm i @soluble/cache-ioredis

Weekly Downloads

339

Version

0.13.11

License

MIT

Unpacked Size

55 kB

Total Files

9

Last publish

Collaborators

  • s.vanvelthem