Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredwray committed Oct 12, 2023
2 parents b2345ef + 66246e9 commit bb1ddda
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
run: npm run build

- name: Test
run: npm run test -- --coverage
run: npm run test

- name: Codecov
uses: codecov/codecov-action@v3
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ NOTES:
* In case of multicaching, the store that will be checked for refresh is the one where the key will be found first (highest priority).
* If the threshold is low and the worker function is slow, the key may expire and you may encounter a racing condition with updating values.
* The background refresh mechanism currently does not support providing multiple keys to `wrap` function.
* If no `ttl` is set for the key, the refresh mechanism will not be triggered. For redis, the `ttl` is set to -1 by default.

For example, pass the refreshThreshold to `caching` like this:

Expand Down Expand Up @@ -223,4 +224,4 @@ for any new features or bug fixes.

## License

node-cache-manager is licensed under the [MIT license](./LICENSE).
node-cache-manager is licensed under the [MIT license](./LICENSE).
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cache-manager",
"version": "5.2.3",
"version": "5.2.4",
"description": "Cache module for Node.js",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand All @@ -9,7 +9,7 @@
],
"scripts": {
"build": "rm -rf dist && tsc -p tsconfig.build.json",
"test": "vitest",
"test": "vitest run --coverage",
"release": "yarn check && yarn test -- --run && yarn build",
"fix": "yarn lint && yarn fmt",
"check": "yarn lint:check && yarn fmt:check",
Expand Down Expand Up @@ -45,23 +45,23 @@
"license": "MIT",
"dependencies": {
"lodash.clonedeep": "^4.5.0",
"lru-cache": "^10.0.0"
"lru-cache": "^10.0.1"
},
"devDependencies": {
"@faker-js/faker": "8.0.2",
"@faker-js/faker": "8.1.0",
"@types/lodash.clonedeep": "4.5.7",
"@types/node": "20.5.9",
"@typescript-eslint/eslint-plugin": "6.6.0",
"@typescript-eslint/parser": "6.6.0",
"@vitest/coverage-v8": "0.34.4",
"@types/node": "20.8.2",
"@typescript-eslint/eslint-plugin": "6.7.4",
"@typescript-eslint/parser": "6.7.4",
"@vitest/coverage-v8": "0.34.6",
"dotenv-cli": "7.3.0",
"eslint": "8.48.0",
"eslint": "8.50.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-prettier": "5.0.0",
"lint-staged": "14.0.1",
"prettier": "3.0.3",
"typescript": "5.2.2",
"vitest": "0.34.4"
"vitest": "0.34.6"
},
"lint-staged": {
"*.{ts,js,mts,mjs}": "eslint --cache --fix",
Expand Down
2 changes: 1 addition & 1 deletion src/caching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export function createCache<S extends Store, C extends Config>(
} else if (args?.refreshThreshold) {
const cacheTTL = typeof ttl === 'function' ? ttl(value) : ttl;
const remainingTtl = await store.ttl(key);
if (remainingTtl < args.refreshThreshold) {
if (remainingTtl !== -1 && remainingTtl < args.refreshThreshold) {
fn().then((result) => store.set<T>(key, result, cacheTTL));
}
}
Expand Down

0 comments on commit bb1ddda

Please sign in to comment.