Kong / Kong/lua-resty-counter

why use dict:incr() not dict:set() in reset() method

Open
#8 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Perl
Stars
23
Forks
10
PR merge metrics
No merged PRs in 30d

Description

if I want to set the key to 0, i can't use `reset(key, 0)`. I need to get a value, and then `reset(key, value)` ?
i am not understand why use `dict:incr()` not `dict:set()` in reset() method
```
function _M:reset(key, number)
if not number then
return nil, "expect a number at #2"
end
return self.dict:incr(key, -number, number)
end
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the reset() method shown in the issue and the dictionary API it calls, especially dict:incr() versus dict:set(). Determine whether reset(key, 0) should be supported and verify the expected behavior for setting a counter to zero.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.