Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@ var crypto = require('crypto');

module.exports = Cacher;

function desymbolize(options) {
if (Array.isArray(options)) {
return options.map(desymbolize);
} else if (typeof options != "object") {
return options;
} else {
let d = Object.assign(Object.create(Object.getPrototypeOf(options)), options);
Object.getOwnPropertySymbols(options).forEach(k => {
d[`<${Symbol.keyFor(k)}>`] = options[k];
delete d[k];
});
Object.keys(d).forEach(k => d[k] = desymbolize(d[k]));
return d;
}
}

/**
* Constructor for cacher
*/
Expand Down Expand Up @@ -240,7 +256,7 @@ Cacher.prototype.key = function key(sql) {
return [this.cachePrefix, '__raw__', 'query', hash].join(':');
}
hash = crypto.createHash('sha1')
.update(CircularJSON.stringify(this.options, jsonReplacer))
.update(CircularJSON.stringify(desymbolize(this.options), jsonReplacer))
.digest('hex');
return [this.cachePrefix, this.modelName, this.method, hash].join(':');
};
Expand Down