flat-cache 3.0.4 → 3.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +4 -2
- package/package.json +14 -37
- package/src/cache.js +23 -2
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# flat-cache
|
|
2
2
|
> A stupidly simple key/value storage using files to persist the data
|
|
3
3
|
|
|
4
|
-
[](https://npmjs.org/package/flat-cache)
|
|
5
|
+
[](https://github.com/jaredwray/flat-cache/actions/workflows/tests.yaml)
|
|
6
|
+
[](https://codecov.io/github/jaredwray/flat-cache)
|
|
7
|
+
[](https://npmjs.com/package/flat-cache)
|
|
6
8
|
|
|
7
9
|
## install
|
|
8
10
|
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flat-cache",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
4
|
"description": "A stupidly simple key/value storage using files to persist some data",
|
|
5
|
-
"repository": "
|
|
5
|
+
"repository": "jaredwray/flat-cache",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": {
|
|
8
|
-
"name": "
|
|
9
|
-
"url": "
|
|
8
|
+
"name": "Jared Wray",
|
|
9
|
+
"url": "https://jaredwray.com"
|
|
10
10
|
},
|
|
11
11
|
"main": "src/cache.js",
|
|
12
12
|
"files": [
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"src/utils.js"
|
|
16
16
|
],
|
|
17
17
|
"engines": {
|
|
18
|
-
"node": "
|
|
18
|
+
"node": ">=12.0.0"
|
|
19
19
|
},
|
|
20
20
|
"precommit": [
|
|
21
21
|
"npm run verify --silent"
|
|
@@ -29,18 +29,9 @@
|
|
|
29
29
|
"autofix": "npm run eslint-fix",
|
|
30
30
|
"check": "npm run eslint",
|
|
31
31
|
"verify": "npm run eslint && npm run test:cache",
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"pre-v": "npm run verify",
|
|
36
|
-
"post-v": "npm run do-changelog && git push --no-verify && git push --tags --no-verify",
|
|
37
|
-
"bump-major": "npm run pre-v && npm version major -m 'BLD: Release v%s' && npm run post-v",
|
|
38
|
-
"bump-minor": "npm run pre-v && npm version minor -m 'BLD: Release v%s' && npm run post-v",
|
|
39
|
-
"bump-patch": "npm run pre-v && npm version patch -m 'BLD: Release v%s' && npm run post-v",
|
|
40
|
-
"test:cache": "mocha -R spec test/specs",
|
|
41
|
-
"test": "npm run verify --silent",
|
|
42
|
-
"cover": "istanbul cover test/runner.js html text-summary",
|
|
43
|
-
"watch": "watch-run -i -p 'test/specs/**/*.js' istanbul cover test/runner.js html text-summary"
|
|
32
|
+
"test:cache": "c8 mocha -R spec test/specs",
|
|
33
|
+
"test:ci:cache": "c8 --reporter=lcov mocha -R spec test/specs",
|
|
34
|
+
"test": "npm run verify --silent"
|
|
44
35
|
},
|
|
45
36
|
"keywords": [
|
|
46
37
|
"json cache",
|
|
@@ -50,35 +41,21 @@
|
|
|
50
41
|
"key value",
|
|
51
42
|
"cache"
|
|
52
43
|
],
|
|
53
|
-
"changelogx": {
|
|
54
|
-
"ignoreRegExp": [
|
|
55
|
-
"BLD: Release",
|
|
56
|
-
"DOC: Generate Changelog",
|
|
57
|
-
"Generated Changelog"
|
|
58
|
-
],
|
|
59
|
-
"issueIDRegExp": "#(\\d+)",
|
|
60
|
-
"commitURL": "https://github.com/royriojas/flat-cache/commit/{0}",
|
|
61
|
-
"authorURL": "https://github.com/{0}",
|
|
62
|
-
"issueIDURL": "https://github.com/royriojas/flat-cache/issues/{0}",
|
|
63
|
-
"projectName": "flat-cache"
|
|
64
|
-
},
|
|
65
44
|
"devDependencies": {
|
|
66
|
-
"
|
|
67
|
-
"
|
|
45
|
+
"c8": "^8.0.1",
|
|
46
|
+
"chai": "^4.3.10",
|
|
68
47
|
"eslint": "^7.13.0",
|
|
69
48
|
"eslint-config-prettier": "^6.15.0",
|
|
70
49
|
"eslint-plugin-mocha": "^8.0.0",
|
|
71
50
|
"eslint-plugin-prettier": "^3.1.4",
|
|
72
51
|
"glob-expand": "^0.2.1",
|
|
73
|
-
"
|
|
74
|
-
"mocha": "^8.2.1",
|
|
75
|
-
"precommit": "^1.2.2",
|
|
76
|
-
"prepush": "^3.1.11",
|
|
52
|
+
"mocha": "^10.2.0",
|
|
77
53
|
"prettier": "^2.1.2",
|
|
78
|
-
"
|
|
54
|
+
"write": "^2.0.0"
|
|
79
55
|
},
|
|
80
56
|
"dependencies": {
|
|
81
|
-
"flatted": "^3.
|
|
57
|
+
"flatted": "^3.2.9",
|
|
58
|
+
"keyv": "^4.5.3",
|
|
82
59
|
"rimraf": "^3.0.2"
|
|
83
60
|
}
|
|
84
61
|
}
|
package/src/cache.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
var path = require('path');
|
|
2
2
|
var fs = require('fs');
|
|
3
|
+
var Keyv = require('keyv');
|
|
3
4
|
var utils = require('./utils');
|
|
4
5
|
var del = require('./del');
|
|
5
6
|
var writeJSON = utils.writeJSON;
|
|
@@ -17,8 +18,10 @@ var cache = {
|
|
|
17
18
|
load: function (docId, cacheDir) {
|
|
18
19
|
var me = this;
|
|
19
20
|
|
|
20
|
-
me.
|
|
21
|
-
|
|
21
|
+
me.keyv = new Keyv();
|
|
22
|
+
|
|
23
|
+
me.__visited = {};
|
|
24
|
+
me.__persisted = {};
|
|
22
25
|
me._pathToFile = cacheDir ? path.resolve(cacheDir, docId) : path.resolve(__dirname, '../.cache/', docId);
|
|
23
26
|
|
|
24
27
|
if (fs.existsSync(me._pathToFile)) {
|
|
@@ -26,6 +29,24 @@ var cache = {
|
|
|
26
29
|
}
|
|
27
30
|
},
|
|
28
31
|
|
|
32
|
+
get _persisted() {
|
|
33
|
+
return this.__persisted;
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
set _persisted(value) {
|
|
37
|
+
this.__persisted = value;
|
|
38
|
+
this.keyv.set('persisted', value);
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
get _visited() {
|
|
42
|
+
return this.__visited;
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
set _visited(value) {
|
|
46
|
+
this.__visited = value;
|
|
47
|
+
this.keyv.set('visited', value);
|
|
48
|
+
},
|
|
49
|
+
|
|
29
50
|
/**
|
|
30
51
|
* Load the cache from the provided file
|
|
31
52
|
* @method loadFile
|