Socket
Socket
Sign inDemoInstall

read-cache

Package Overview
Dependencies
1
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    read-cache

Reads and caches the entire contents of a file until it is modified


Version published
Weekly downloads
10M
increased by3.18%
Maintainers
1
Install size
11.6 kB
Created
Weekly downloads
 

Package description

What is read-cache?

The `read-cache` npm package is designed to read and cache the contents of files in memory. This can significantly improve performance for applications that need to read the same files multiple times, as it avoids unnecessary disk I/O after the initial read. The cache is automatically updated if the file changes, ensuring that the application always has access to the latest version of the file contents.

What are read-cache's main functionalities?

Reading and caching file contents

This feature allows you to read the contents of a file and cache it for future reads. The function returns a promise that resolves with the file's contents.

const readCache = require('read-cache');
readCache('path/to/file.txt').then(contents => {
  console.log(contents);
});

Synchronously reading and caching file contents

Similar to the asynchronous version, this feature allows for synchronous reading and caching of file contents, useful in scenarios where asynchronous operations are not possible or desired.

const readCache = require('read-cache');
const contents = readCache.sync('path/to/file.txt');
console.log(contents);

Other packages similar to read-cache

Readme

Source

read-cache Build Status

Reads and caches the entire contents of a file until it is modified.

Install

$ npm i read-cache

Usage

// foo.js
var readCache = require('read-cache');

readCache('foo.js').then(function (contents) {
	console.log(contents);
});

API

readCache(path[, encoding])

Returns a promise that resolves with the file's contents.

readCache.sync(path[, encoding])

Returns the content of the file.

readCache.get(path[, encoding])

Returns the content of cached file or null.

readCache.clear()

Clears the contents of the cache.

License

MIT © Bogdan Chadkin

Keywords

FAQs

Last updated on 11 Jan 2016

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