Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

kashmir

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kashmir

Cache optimised for medium to large files

latest
Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
512
64.1%
Maintainers
1
Weekly downloads
 
Created
Source

kashmir

NodeJS base cache optimised for medium to large data files.

The cached data is stored in local files honoring a maximum storage capacity.

Files gets evicted following a LRU policy and a minimum TTL policy. A cached entry can only be evicted if it has passed more than TTL milliseconds since it last hit. You can disable the TTL policy by specifying 0 milliseconds, otherswise defaults to one hour.

Entries to be cached can include a "meta" data object for user define metadata that must be stored along the cached entries.

Notes:

  • the cache is not designed to work for several processes accessing to it at the same time.
  • setting the same key more than once if the key is already cached will just be ignored.

Usage

var cache = new kashmir.Cache('/my/cache/dir', {
  ttl: 1000 * 60 * 60, //  defaults to 1 hour.
  maxSize: 1024 * 1024 * 256 // defaults to 256Mb.
});

cache.set('mykey', sourceStream, size, meta).then( (cached) => {
  // cached true if the sourceStream could be cached.

});


cache.get('mykey').then( (cached) => {
  /* returns cached if entry was cached with the following data:
    {
      size: size,
      stream: stream,
      meta: meta
    }
  */
});

Keywords

cache

FAQs

Package last updated on 02 Mar 2018

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