diff --git a/lib/index.js b/lib/index.js index 0735583..7efc2a3 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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 */ @@ -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(':'); };