3.0.0 • Published 7 months ago

@varasto/redis-storage v3.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

@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 => "",
});
3.0.0

7 months ago

2.0.0

7 months ago

1.1.0

3 years ago

1.0.0

3 years ago