New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@neoskop/redis-promise-cache

Package Overview
Dependencies
Maintainers
11
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@neoskop/redis-promise-cache

Store promises and synchrone values in redis

  • 0.4.2
  • next
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13
decreased by-40.91%
Maintainers
11
Weekly downloads
 
Created
Source

@neoskop/redis-promise-cache

Build Coverage

Store promises and synchrone values in redis.

Prevents multiple redundant calls to the same (expensive) resource. See here for more details.

Usage

import { RedisPromiseCache } from '@neoskop/redis-promise-cache'

const cache = new RedisPromiseCache({ resourceTag: 'db' });
const db : any;

/**
 *  with helper method 
 */
async function getResource(id : string) {
    return cache.getResource(id, () => db.get(id));
}

/**
 *  with "low level" api
 */
async function getResource2(id : string) {
    const cacheEntry = cache.get(id);
    if(cacheEntry) {
        return cacheEntry;
    }

    const promise = db.get(id);
    cache.set(id, promise);

    return promise;
}

Testing

Run tests with yarn test. See package.json for additional test scripts.

Versioning

This package follows SemVer and uses @neoskop/flow-bump for versioning.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Keywords

FAQs

Package last updated on 28 Jan 2022

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