-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Description
code
var redback = require('redback').createClient();
var ratelimit = redback.createRateLimit('requests', {
bucket_span: 6,
bucket_interval: 1,
subject_expiry: 12
});
// if request 1 times per 3 seconds
setInterval(function () {
ratelimit.add('127.0.0.1');
}, 3000);redis monitor
1475139642.585969 [0 127.0.0.1:50241] "multi"
1475139642.585994 [0 127.0.0.1:50241] "hincrby" "requests:127.0.0.1" "0" "1"
1475139642.586005 [0 127.0.0.1:50241] "hdel" "requests:127.0.0.1" "1"
1475139642.586010 [0 127.0.0.1:50241] "hdel" "requests:127.0.0.1" "2"
1475139642.586015 [0 127.0.0.1:50241] "expire" "requests:127.0.0.1" "12"
1475139642.586023 [0 127.0.0.1:50241] "exec"
1475139645.592772 [0 127.0.0.1:50241] "multi"
1475139645.592794 [0 127.0.0.1:50241] "hincrby" "requests:127.0.0.1" "3" "1"
1475139645.592804 [0 127.0.0.1:50241] "hdel" "requests:127.0.0.1" "4"
1475139645.592809 [0 127.0.0.1:50241] "hdel" "requests:127.0.0.1" "5"
1475139645.592814 [0 127.0.0.1:50241] "expire" "requests:127.0.0.1" "12"
1475139645.592822 [0 127.0.0.1:50241] "exec"
1475139648.594619 [0 127.0.0.1:50241] "multi"
1475139648.594651 [0 127.0.0.1:50241] "hincrby" "requests:127.0.0.1" "0" "1"
1475139648.594669 [0 127.0.0.1:50241] "hdel" "requests:127.0.0.1" "1"
1475139648.594677 [0 127.0.0.1:50241] "hdel" "requests:127.0.0.1" "2"
1475139648.594685 [0 127.0.0.1:50241] "expire" "requests:127.0.0.1" "12"
1475139648.594698 [0 127.0.0.1:50241] "exec"
1475139651.597944 [0 127.0.0.1:50241] "multi"
1475139651.597967 [0 127.0.0.1:50241] "hincrby" "requests:127.0.0.1" "3" "1"
1475139651.597978 [0 127.0.0.1:50241] "hdel" "requests:127.0.0.1" "4"
1475139651.597983 [0 127.0.0.1:50241] "hdel" "requests:127.0.0.1" "5"
1475139651.597987 [0 127.0.0.1:50241] "expire" "requests:127.0.0.1" "12"
1475139651.597995 [0 127.0.0.1:50241] "exec"
bucket 0 and 3 will not be deleted.
now I'd like to get the count on bucket 0, it's 2.
actually I just hit 1 times in this second, or in last 2 seconds.
wendy260310
Metadata
Metadata
Assignees
Labels
No labels