flat-cache
Advanced tools
Comparing version 1.0.10 to 1.2.0
11
cache.js
var path = require( 'path' ); | ||
var fs = require( 'graceful-fs' ); | ||
var readJSON = require( 'read-json-sync' ); | ||
var write = require( 'write' ); | ||
var del = require( 'del' ).sync; | ||
var readJSON = require( './utils' ).readJSON; | ||
var writeJSON = require( './utils' ).writeJSON; | ||
@@ -103,9 +103,10 @@ var cache = { | ||
* as a JSON structure | ||
* @param [noPrune=false] {Boolean} whether to remove from cache the non visited files | ||
* @method save | ||
*/ | ||
save: function () { | ||
save: function ( noPrune ) { | ||
var me = this; | ||
me._prune(); | ||
write.sync( me._pathToFile, JSON.stringify( me._persisted ) ); | ||
(!noPrune) && me._prune(); | ||
writeJSON( me._pathToFile, me._persisted ); | ||
}, | ||
@@ -112,0 +113,0 @@ |
# flat-cache - Changelog | ||
## v1.2.0 | ||
- **Documentation** | ||
- Add documentation about noPrune option - [23e11f9]( https://github.com/royriojas/flat-cache/commit/23e11f9 ), [Roy Riojas](https://github.com/Roy Riojas), 01/08/2016 04:06:49 | ||
## v1.0.11 | ||
- **Features** | ||
- Add noPrune option to cache.save() method. closes [#7](https://github.com/royriojas/flat-cache/issues/7) - [2c8016a]( https://github.com/royriojas/flat-cache/commit/2c8016a ), [Roy Riojas](https://github.com/Roy Riojas), 01/08/2016 04:00:29 | ||
- Add json read and write utility based on circular-json - [c31081e]( https://github.com/royriojas/flat-cache/commit/c31081e ), [Jean Ponchon](https://github.com/Jean Ponchon), 28/07/2016 10:58:17 | ||
- **Bug Fixes** | ||
- Remove UTF16 BOM stripping - [4a41e22]( https://github.com/royriojas/flat-cache/commit/4a41e22 ), [Jean Ponchon](https://github.com/Jean Ponchon), 29/07/2016 04:18:06 | ||
Since we control both writing and reading of JSON stream, there no needs | ||
to handle unicode BOM. | ||
- Use circular-json to handle circular references (fix [#5](https://github.com/royriojas/flat-cache/issues/5)) - [cd7aeed]( https://github.com/royriojas/flat-cache/commit/cd7aeed ), [Jean Ponchon](https://github.com/Jean Ponchon), 25/07/2016 13:11:59 | ||
- **Tests Related fixes** | ||
- Add missing file from eslint test - [d6fa3c3]( https://github.com/royriojas/flat-cache/commit/d6fa3c3 ), [Jean Ponchon](https://github.com/Jean Ponchon), 29/07/2016 04:15:51 | ||
- Add test for circular json serialization / deserialization - [07d2ddd]( https://github.com/royriojas/flat-cache/commit/07d2ddd ), [Jean Ponchon](https://github.com/Jean Ponchon), 28/07/2016 10:59:36 | ||
- **Refactoring** | ||
- Remove unused read-json-sync - [2be1c24]( https://github.com/royriojas/flat-cache/commit/2be1c24 ), [Jean Ponchon](https://github.com/Jean Ponchon), 28/07/2016 10:59:18 | ||
- **Build Scripts Changes** | ||
- travis tests on 0.12 and 4x - [3a613fd]( https://github.com/royriojas/flat-cache/commit/3a613fd ), [royriojas](https://github.com/royriojas), 15/11/2015 17:34:40 | ||
## v1.0.10 | ||
@@ -4,0 +40,0 @@ - **Build Scripts Changes** |
{ | ||
"name": "flat-cache", | ||
"version": "1.0.10", | ||
"version": "1.2.0", | ||
"description": "A stupidly simple key/value storage using files to persist some data", | ||
@@ -25,5 +25,5 @@ "repository": "royriojas/flat-cache", | ||
"scripts": { | ||
"beautify": "esbeautifier 'cache.js' 'specs/**/*.js'", | ||
"beautify": "esbeautifier 'cache.js' 'test/specs/**/*.js'", | ||
"beautify-check": "npm run beautify -- -k", | ||
"eslint": "eslinter 'cache.js' 'specs/**/*.js'", | ||
"eslint": "eslinter 'cache.js' 'utils.js' 'specs/**/*.js'", | ||
"eslint-fix": "npm run eslint -- --fix", | ||
@@ -82,7 +82,7 @@ "autofix": "npm run beautify && npm run eslint-fix", | ||
"dependencies": { | ||
"circular-json": "^0.3.0", | ||
"del": "^2.0.2", | ||
"graceful-fs": "^4.1.2", | ||
"read-json-sync": "^1.1.0", | ||
"write": "^0.2.1" | ||
} | ||
} |
@@ -32,2 +32,3 @@ # flat-cache | ||
cache.save(); // very important, if you don't save no changes will be persisted. | ||
// cache.save( true /* noPrune */) // can be used to prevent the removal of non visited keys | ||
@@ -61,2 +62,4 @@ // loads the cache from a given directory, if one does | ||
intentionally dumb and simple | ||
- Non visited keys are removed when `cache.save()` is called. If this is not desired, you can pass `true` to the save call | ||
like: `cache.save( true /* noPrune */ )`. | ||
@@ -63,0 +66,0 @@ ## License |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17606
170
72
+ Addedcircular-json@^0.3.0
+ Addedcircular-json@0.3.3(transitive)
- Removedread-json-sync@^1.1.0
- Removedread-json-sync@1.1.1(transitive)