Socket
Socket
Sign inDemoInstall

cachepot

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cachepot

Itsy-bitsy cache module. Smells as good as flowers.


Version published
Weekly downloads
1
decreased by-90%
Maintainers
1
Install size
3.88 kB
Created
Weekly downloads
 

Readme

Source

cachepot · Build Status Codecov

Itsy-bitsy cache module. Smells as good as flowers.

Usage

Cachepot has almost the same external-facing API as the ES6 Map, but with some additional methods and configuration options.

const cache = new Cachepot()
cache.set('key', 'value')
cache.get('key')
cache.wrap('key', () => 'value')
new Cachepot(options)
KeyDescriptionDefault
ttlTime in milliseconds until the key/value pair expires.60 x 60
cache.wrap(key, callback)

This method will either return the value if it exists, or set a new one by calling the callback function. The return value of the function will be set as the new value for the key.

const cache = new Cachepot()
cache.wrap('key', () => {
  const value = createComplicatedObject()
  return value
})
cache.set(key, value, ttl)

This method has the same API as Map.set(), but with an additional optional ttl argument. This will override the configured TTL option.

Keywords

FAQs

Last updated on 31 Dec 2017

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc