set cache time

master
DIYgod 6 years ago
parent fc124f0245
commit fcffffc857
No known key found for this signature in database
GPG Key ID: EC0B76A252D3EF67
  1. 2
      routes/bilibili.js
  2. 4
      utils/redis.js

@ -36,7 +36,7 @@ module.exports = async (ctx) => {
}
return [[parseFloat(p[0]), type, parseInt(p[3]), p[6], item.text()]];
}).get();
ctx.redis.set(`v3bilibilicid2dan${cid}`, JSON.stringify(data));
ctx.redis.set(`v3bilibilicid2dan${cid}`, JSON.stringify(data), 10 * 60);
ctx.response.set('X-Koa-Origin', 'true');
}
ctx.body = JSON.stringify({

@ -24,9 +24,9 @@ client.on('connect', () => {
const getAsync = promisify(client.get).bind(client);
module.exports = {
set: (key, value) => {
set: (key, value, maxAge = 30 * 24 * 60 * 60) => {
logger.info('Set redis: ' + key);
client.set(key, value);
client.setex(key, maxAge, value);
},
get: async (key) => await getAsync(key),
del: (key) => {

Loading…
Cancel
Save