Socket
Socket
Sign inDemoInstall

async-memo-ize-plugin-redis-cache

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-memo-ize-plugin-redis-cache

Async Redis cache


Version published
Weekly downloads
10
Maintainers
1
Weekly downloads
 
Created
Source

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

FAQs

Package last updated on 12 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc