@varasto/redis-storage
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

@varasto/redis-storage

npm

Implementation of storage that uses Redis as backend for storing data.

Installation

$ npm install --save @varasto/redis-storage

Usage

The package provides an function called createRedisStorage which takes an Redis client as an argument.

import { createClient } from 'redis';
import { createRedisStorage } from '@varasto/redis-storage';

const client = createClient({ host: 'example.com' });
const storage = createRedisStorage(client);

Custom serializers

By default, JSON.stringify is used for serializing data passed to Redis and JSON.parse is used for deserializing coming from Redis. However you can also use your own custom serialization functions by passing them as options to the createRedisStorage function.

import { createClient } from 'redis';
import { createRedisStorage } from '@varasto/redis-storage';
import { JsonObject } from 'type-fest';

const client = createClient({ host: 'example.com' });
const storage = createRedisStorage(client, {
  serialize: (data: string): JsonObject => {},
  deserialize: (data: JsonObject): string => "",
});

Readme

Keywords

Package Sidebar

Install

npm i @varasto/redis-storage

Weekly Downloads

1

Version

3.0.0

License

MIT

Unpacked Size

12.8 kB

Total Files

10

Last publish

Collaborators

  • rauli