file-entry-cache
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
flat-cache | 3.2.0 | 8.59 kB | MIT | prod |
File-entry-cache is a supremely simple caching solution for file metadata that proves particularly useful in processes that work on a series of files. Its key functionality is to remember the state of files from the previous session, and consequently, only repeats tasks on the files that have changed. File-entry-cache works on the basis of in-memory cache and optional disk persistence, thereby providing a solution that improves speed and efficiency.
To properly utilize file-entry-cache, you should first install the module using npm, with the following command:
npm i --save file-entry-cache
Once installed, the module makes available two functions, create
and createFromFile
. A small example using these functions may look like this:
var fileEntryCache = require('file-entry-cache');
var cache = fileEntryCache.create('testCache');
var files = expand('../fixtures/*.txt');
var oFiles = cache.getUpdatedFiles(files);
cache.reconcile();
In this instance, create
is used to load the cache, preparing a new one if an existing one doesn't exist for the given Id. After that, you may persist the cache to the disk, for which you can use the reconcile
function to update/check each file's status and some optional custom fields. getUpdatedFiles
will return the files that were modified since the previous session of work.
You'll find the most extensive documentation for file-entry-cache on its GitHub page: file-entry-cache. Additionally, you can find more information on the package on its npm page: file-entry-cache npm.