0.1.8 • Published 7 years ago

async-memo-ize-plugin-redis-cache v0.1.8

Weekly downloads
-
License
MIT
Repository
-
Last release
7 years ago

Async Memo-ize Plugin Redis Cache

This plugin allow async-memo-ize to distribute cache between multiple NodeJS instances

Install

npm install async-memo-ize-plugin-redis-cache

or

yarn add  async-memo-ize-plugin-redis-cache

Usage

import memoize from 'async-memo-ize'
import RedisCache from 'async-memo-ize-plugin-redis-cache'

const fn = async () => 42
const memoized = memoize(fn, new RedisCache())

const anser = await memoized()

Notice

The key name, serialized on Redis, is based on the named function args and his name.

Given:

const doSomething = async (a, b) => a+b

The key generated:

["doSomething",1,5]

It means multiple NodeJs instances can share the value computed if the function name and the args match. If you prefer to use an anonymous function it is required to pass an id as option

Test

Prerequisites

docker run -d -p 6379:6379 redis:alpine  

Run

yarn test
0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago