Socket
Socket
Sign inDemoInstall

file-entry-cache

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

file-entry-cache - npm Package Compare versions

Comparing version 1.2.4 to 1.3.0

10

cache.js

@@ -19,3 +19,3 @@ var path = require( 'path' );

/**
* the flat cache storage used to persist the metadata of the files
* the flat cache storage used to persist the metadata of the `files
* @type {Object}

@@ -165,12 +165,14 @@ */

* Sync the files and persist them to the cache
*
* @param [noPrune=false] {Boolean} whether to remove non visited/saved entries
* @method reconcile
*/
reconcile: function () {
reconcile: function ( noPrune ) {
var entries = normalizedEntries;
var keys = Object.keys( entries );
if ( keys.length === 0 ) {
return;
}
keys.forEach( function ( entryName ) {

@@ -188,3 +190,3 @@ var cacheEntry = entries[ entryName ];

cache.save();
cache.save( noPrune );
}

@@ -191,0 +193,0 @@ };

# file-entry-cache - Changelog
## v1.3.0
- **Features**
- Add an option to not prune non visited keys. Closes [#2](https://github.com/royriojas/file-entry-cache/issues/2) - [b1a64db]( https://github.com/royriojas/file-entry-cache/commit/b1a64db ), [Roy Riojas](https://github.com/Roy Riojas), 01/08/2016 05:52:12
## v1.2.4

@@ -4,0 +9,0 @@ - **Enhancements**

15

package.json
{
"name": "file-entry-cache",
"version": "1.2.4",
"version": "1.3.0",
"description": "Super simple cache for file metadata, useful for process that work o a given series of files and that only need to repeat the job on the changed ones since the previous run of the process",

@@ -19,4 +19,4 @@ "repository": "royriojas/file-entry-cache",

"scripts": {
"beautify": "esbeautifier 'cache.js' 'specs/**/*.js'",
"beautify-check": "esbeautifier -k 'cache.js' 'specs/**/*.js'",
"beautify": "esbeautifier 'cache.js' 'test/**/*.js'",
"beautify-check": "npm run beautify -- -k",
"eslint": "eslinter 'cache.js' 'specs/**/*.js'",

@@ -28,3 +28,3 @@ "lint": "npm run beautify && npm run eslint",

"do-changelog": "npm run changelog && git add ./changelog.md && git commit -m 'DOC: Generate changelog' --no-verify",
"pre-v": "npm run verify",
"pre-v": "npm run test",
"post-v": "npm run do-changelog && git push --no-verify && git push --tags --no-verify",

@@ -34,3 +34,3 @@ "bump-major": "npm run pre-v && npm version major -m 'BLD: Release v%s' && npm run post-v",

"bump-patch": "npm run pre-v && npm version patch -m 'BLD: Release v%s' && npm run post-v",
"test": "mocha -R spec test/specs",
"test": "npm run verify && mocha -R spec test/specs",
"cover": "istanbul cover test/runner.js html text-summary",

@@ -78,12 +78,11 @@ "watch": "watch-run -i -p 'test/specs/**/*.js' istanbul cover test/runner.js html text-summary"

"proxyquire": "^1.3.1",
"read-file": "^0.2.0",
"sinon": "^1.12.2",
"sinon-chai": "^2.7.0",
"watch-run": "^1.2.1",
"write": "^0.2.1"
"write": "^0.3.1"
},
"dependencies": {
"flat-cache": "^1.0.9",
"flat-cache": "^1.2.1",
"object-assign": "^4.0.1"
}
}
# file-entry-cache
> Super simple cache for file metadata, useful for process that work o a given series of files
> Super simple cache for file metadata, useful for process that work o a given series of files
> and that only need to repeat the job on the changed ones since the previous run of the process — Edit

@@ -17,3 +17,3 @@

```js
// loads the cache, if one does not exists for the given
// loads the cache, if one does not exists for the given
// Id a new one will be prepared to be created

@@ -29,8 +29,13 @@ var fileEntryCache = require('file-entry-cache');

// this will persist this to disk checking each file stats and
// this will persist this to disk checking each file stats and
// updating the meta attributes `size` and `mtime`.
// custom fields could also be added to the meta object and will be persisted
// in order to retrieve them later
cache.reconcile();
cache.reconcile();
// use this if you want the non visited file entries to be kept in the cache
// for more than one execution
//
// cache.reconcile( true /* noPrune */)
// on a second run

@@ -41,3 +46,3 @@ var cache2 = fileEntryCache.create('testCache');

// if no files were modified previous to the execution of this function
var oFiles = cache.getUpdatedFiles(files);
var oFiles = cache.getUpdatedFiles(files);

@@ -70,3 +75,3 @@ // if you want to prevent a file from being considered non modified

I needed a super simple and dumb **in-memory cache** with optional disk persistence (write-back cache) in order to make
I needed a super simple and dumb **in-memory cache** with optional disk persistence (write-back cache) in order to make
a script that will beautify files with `esformatter` to execute only on the files that were changed since the last run.

@@ -76,12 +81,12 @@

This module uses [flat-cache](https://www.npmjs.com/package/flat-cache) a super simple `key/value` cache storage with
This module uses [flat-cache](https://www.npmjs.com/package/flat-cache) a super simple `key/value` cache storage with
optional file persistance.
The main idea is to read the files when the task begins, apply the transforms required, and if the process succeed,
then store the new state of the files. The next time this module request for `getChangedFiles` will return only
The main idea is to read the files when the task begins, apply the transforms required, and if the process succeed,
then store the new state of the files. The next time this module request for `getChangedFiles` will return only
the files that were modified. Making the process to end faster.
This module could also be used by processes that modify the files applying a transform, in that case the result of the
transform could be stored in the `meta` field, of the entries. Anything added to the meta field will be persisted.
Those processes won't need to call `getChangedFiles` they will instead call `normalizeEntries` that will return the
transform could be stored in the `meta` field, of the entries. Anything added to the meta field will be persisted.
Those processes won't need to call `getChangedFiles` they will instead call `normalizeEntries` that will return the
entries with a `changed` field that can be used to determine if the file was changed or not. If it was not changed

@@ -94,9 +99,15 @@ the transformed stored data could be used instead of actually applying the transformation, saving time in case of only

## Important notes
- The values set on the meta attribute of the entries should be `stringify-able` ones, meaning no circular references
- All the changes to the cache state are done to memory first and only persisted after reconcile
- The values set on the meta attribute of the entries should be `stringify-able` ones if possible, flat-cache uses `circular-json` to try to persist circular structures, but this should be considered experimental. The best results are always obtained with non circular values
- All the changes to the cache state are done to memory first and only persisted after reconcile.
- By default non visited entries are removed from the cache. This is done to prevent the file from growing too much. If this is not an issue and
you prefer to do a manual pruning of the cache files, you can pass `true` to the `reconcile` call. Like this:
## License
```javascript
cache.reconcile( true /* noPrune */ );
```
## License
MIT
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