Back to Lo

Core Newthrottlebywithcount

docs/data/core-newthrottlebywithcount.md

1.53.0283 B
Original Source

Creates a throttled function per key with a per-interval invocation limit.

go
throttle, reset := lo.NewThrottleByWithCount[string](
    100*time.Millisecond,
    3,
    func(key string) {
        println(key)
    },
)

for i := 0; i < 10; i++ {
    throttle("foo")
}

reset()