Socket
Socket
Sign inDemoInstall

simple-in-memory-cache

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    simple-in-memory-cache

A simple in-memory cache, for nodejs and the browser, with time based expiration policies.


Version published
Weekly downloads
516
Maintainers
1
Created
Weekly downloads
 

Changelog

Source

0.3.1 (2023-07-28)

Bug Fixes

  • inputs: add seconds as alias to defaultSecondsUntilExpiration (4ad0a09)
  • practs: use latest best practices (0937888)

Readme

Source

simple-in-memory-cache

test publish

A simple in-memory cache, for nodejs and the browser, with time based expiration policies.

Install

npm install --save simple-in-memory-cache

Example

Quickly set and get from the cache:

import { createCache } from 'simple-in-memory-cache';

const { set, get } = createCache();
set('meaning of life', 42);
const meaningOfLife = get('meaning of life'); // returns 42

Items in the cache live 5 minutes until expiration, by default.

You can change this default when creating the cache:

const { set, get } = createCache({ defaultSecondsUntilExpiration: 10 * 60 }); // updates the default seconds until expiration to 10 minutes

And you can also override this when setting an item:

set('acceleration due to gravity', 9.81, { secondsUntilExpiration: Infinity }); // gravity will not change, so we dont need to expire it

Keywords

FAQs

Last updated on 28 Jul 2023

Did you know?

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc