Skip to content

Instantly share code, notes, and snippets.

@Prosen-Ghosh
Created January 22, 2023 14:49
Show Gist options
  • Save Prosen-Ghosh/6281a236ba04ae78d62c31d70d461ca2 to your computer and use it in GitHub Desktop.
Save Prosen-Ghosh/6281a236ba04ae78d62c31d70d461ca2 to your computer and use it in GitHub Desktop.
const Redis = require("ioredis");
const redis = new Redis();
app.post("/login", async (req, res) => {
const userId = req.body.userId;
const timestamp = Date.now();
const bitmapKey = `user_login:${userId}`;
const offset = Math.floor(timestamp / (24 * 60 * 60 * 1000));
await redis.setbit(bitmapKey, offset, 1);
res.send("User login recorded!");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment