-
Notifications
You must be signed in to change notification settings - Fork 22
Closed
Description
I have read the code, there is something I do not understand. I know that this module using sorted set in redis to save the request time in ms . But I do not see some code for delete the old ones . I see the whole logic is this part of code:
const res = await db
.multi()
.zrange([key, 0, start, 'WITHSCORES'])
.zcard([key])
.zadd([key, now, now])
.zrange([key, 0, 0])
.pexpire([key, duration])
.exec()
zcard is always reading the whole set when the set data is not expired. And every time the request comes, the set can not expire.
So if I set a duration of 10 min and max count for 10 and request is send to server with same id for two mins a time and the set data is always growing when it reach the max count ,which is clearly not what we want.
Hope you can understand my poor English
Metadata
Metadata
Assignees
Labels
No labels