Skip to content
This repository was archived by the owner on Oct 13, 2025. It is now read-only.

Commit b0dc8de

Browse files
committed
fix #44 - Merge branch 'SassNinja-feature/fix-default-options'
2 parents a4a6e31 + 97439ea commit b0dc8de

File tree

8 files changed

+88
-43
lines changed

8 files changed

+88
-43
lines changed

lib/library.js

Lines changed: 20 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/library.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/library.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/library.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/hooks/cache.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
/**
22
* After hook - generates a cache object that is needed
33
* for the redis hook and the express middelware.
4-
* @todo add default value in config file
54
*/
6-
const defaults = {};
5+
const defaults = {
6+
defaultDuration: 3600 * 24
7+
};
78

89
export function cache(options) { // eslint-disable-line no-unused-vars
9-
options = Object.assign({}, defaults, options);
10-
1110
return function (hook) {
11+
const cacheOptions = hook.app.get('redisCache');
12+
13+
options = Object.assign({}, defaults, cacheOptions, options);
14+
1215
if (!hook.result.hasOwnProperty('cache')) {
1316
let cache = {};
1417

@@ -21,7 +24,7 @@ export function cache(options) { // eslint-disable-line no-unused-vars
2124

2225
cache = Object.assign({}, cache, {
2326
cached: false,
24-
duration: options.duration || 3600 * 24
27+
duration: options.duration || options.defaultDuration
2528
});
2629

2730
hook.result.cache = cache;
@@ -31,8 +34,6 @@ export function cache(options) { // eslint-disable-line no-unused-vars
3134
};
3235

3336
export function removeCacheInformation(options) { // eslint-disable-line no-unused-vars
34-
options = Object.assign({}, defaults, options);
35-
3637
return function (hook) {
3738
if (hook.result.hasOwnProperty('cache')) {
3839
delete hook.result.cache;

0 commit comments

Comments
 (0)