Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mish-tv/cache

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mish-tv/cache

A simple cache library with support for exclusion control.

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

@mish-tv/cache

npm Build and test coverage license
`@mish-tv/cache` is a simple cache library that holds a single value in a single instance.

Installation

npm install --save @mish-tv/cache

Simple Usage

import { Cache } from "@mish-tv/cache";

// By default, it caches for 1hour + rand()*6min.
const entityCache = new Cache<Entity>();

// Only at the beginning and when it expires,
// it calls an anonymous function passed as an argument and
// caches the returned value.
const getEntity = () =>
  entityCache.get(async () => {
    const entity: Entity = await fetch();

    return entity;
  });

(async () => {
  const entity = await getEntity();
})();

Other Usage

// You can configure ttl, jitter and initial value.
const entityCache = new Cache(60000, 1000, entity);

// You can create a cache that will never expire.
const entityCache = new Cache("infinity");

FAQs

Package last updated on 06 Jan 2023

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