Skip to content

Commit

Permalink
update redis config
Browse files Browse the repository at this point in the history
  • Loading branch information
feruzm committed Jul 24, 2023
1 parent df72b2f commit 34f17dc
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/server/handlers/private-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,16 +468,33 @@ export const activities = async (req: express.Request, res: express.Response) =>
});
await client.connect();
const redis = new Redis(client);

const rec = await redis.get(identifier);
let rec;
try {
rec = await redis.get(identifier);
} catch (e) {
console.error(e);
console.error("Redis is unavailable. Cache ignoring");
}

if (rec) {
if (new Date().getTime() - new Date(Number(rec)).getTime() < 900000) {
res.status(201).send({})
return
}
await redis.set(identifier, new Date().getTime().toString());
try {
await redis.set(identifier, new Date().getTime().toString());
} catch (error) {
console.error(error);
console.error("Redis is unavailable. Cache ignoring");
}

} else {
await redis.set(identifier, new Date().getTime().toString());
try {
await redis.set(identifier, new Date().getTime().toString());
} catch (error) {
console.error(error);
console.error("Redis is unavailable. Cache ignoring");
}
}
}

Expand Down

0 comments on commit 34f17dc

Please sign in to comment.