0.12.11 • Published 10 months ago

@soluble/cache-redis v0.12.11

Weekly downloads
6
License
MIT
Repository
github
Last release
10 months ago

About | Documentation

Cache adapter for node redis client.

Install

$ yarn add @soluble/cache-redis redis
$ yarn add @types/redis --dev

Usage

import { RedisCacheAdapter } from "@soluble/cache-redis";

const cache = new RedisCacheAdapter({
  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

RedisAdapter connection param can be a DSN, a RedisConnection, the native ClientOpts or an existing RedisClient connection.

You can use the getRedisOptionsFromDsn function to initiate a connection with native parameters.

import {
  RedisCacheAdapter,
  getRedisOptionsFromDsn,
} from "@soluble/cache-redis";

const dsn = "redis://localhost:6379/db2";

const cache = new RedisCacheAdapter({
  connection: getRedisOptionsFromDsn(dsn, {
    // here all node-redis client options
    enable_offline_queue: false,
  }),
});

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

0.12.11

10 months ago

0.12.10

12 months ago

0.12.7

1 year ago

0.12.8

1 year ago

0.12.9

1 year ago

0.12.4

1 year ago

0.12.5

1 year ago

0.12.6

1 year ago

0.11.0

2 years ago

0.11.1

2 years ago

0.11.1-canary.2

2 years ago

0.10.0

2 years ago

0.11.1-canary.0

2 years ago

0.11.1-canary.1

2 years ago

0.10.0-canary.1

2 years ago

0.9.2-canary.0

2 years ago

0.9.0

2 years ago

0.9.1

2 years ago

0.8.6

2 years ago

0.8.3-canary.3

3 years ago

0.8.3-canary.2

3 years ago

0.8.3-canary.1

3 years ago

0.8.3

2 years ago

0.8.1

3 years ago

0.8.0

3 years ago

0.8.2

3 years ago

0.7.1

3 years ago

0.7.0

3 years ago

0.6.0

3 years ago

0.5.0

3 years ago

0.4.2

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.2

3 years ago