Skip to content

Commit

Permalink
fix object cache key error
Browse files Browse the repository at this point in the history
  • Loading branch information
nondanee committed Feb 3, 2020
1 parent 9a0357f commit 1031243
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const collector = (job, cycle) =>
module.exports = (job, parameter, live = 30 * 60 * 1000) => {
const cache = job.cache ? job.cache : job.cache = {}
if (!job.collector) job.collector = collector(job, live / 2)
const key = parameter == null ? 'default' : (parameter.id || parameter.key || parameter)
const key = parameter == null ? 'default' : (typeof(parameter) === 'object' ? (parameter.id || parameter.key || JSON.stringify(parameter)) : parameter)
if (!cache[key] || cache[key].expiration < Date.now())
cache[key] = {
execution: job(parameter),
Expand Down
1 change: 1 addition & 0 deletions provider/qq.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ const ticket = (id, format) => {
}

const track = id => {
id.key = id.file
return Promise.all(
[['F000', '.flac'], ['M800', '.mp3'], ['M500', '.mp3']].slice((headers.cookie || typeof(window) !== 'undefined') ? 1 : 2)
.map(format => ticket(id, format).catch(() => null).then(vkey => ({vkey, format})))
Expand Down

0 comments on commit 1031243

Please sign in to comment.