Created
January 22, 2023 14:49
-
-
Save Prosen-Ghosh/6281a236ba04ae78d62c31d70d461ca2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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