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

filestream-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

filestream-cache

Cache stream content transparently.

  • 1.2.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

filestream-cache

Cache stream content transparently.

Why is this preferred to storing content in 'memory'? Despite an 'in memory' cache being very fast, the object must be stored as a Javascript String which is subject to the memory manager of the runtime, it often doesn't make sense to do memory management in our application when the operating system can do a better job.

This method of caching defers the memory management to the operating system. The content is cached by writing to the filesystem transparently and then reading from it. Frequently used items are then naturally cached by the operating system's disk buffer cache.

Usage

API

get(identifier, options, createCallback)
purge(filter)
isStale(identifier)
writeThrough(identifier, stream)

Example

var Cache = require('filestream-cache');

// Create the cache providing a location on the filesystem to store the cached
// objects
var cache = new Cache('/tmp/myappcache');

// Get a cached object by the cache key.  If the object does not exist, create
// and cache it via the callback.
var stream = cache.get('cachekey', {}, function createStream() {
	return generateMyCacheableStream();
});

stream.pipe(process.stdout);

License

MIT

FAQs

Package last updated on 08 Jun 2015

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