Skip to content

The sorted set holds the old request data #3

@amanda94

Description

@amanda94

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions