Per-key rate limiting — one independent Cooldown per key, created on demand.

On the server this is the standard shape for "once per player per second":

var limiter = new KeyedCooldown(1000);
Events.onNet("shop:buy", (item:String) -> {
    var source = Events.source();
    if (!limiter.tryUse(Std.string(source))) return;
    sell(source, item);
});

Keys are held until forget or clear is called, so drop a player's key when they disconnect if you're limiting by source.

Constructor

new(intervalMs:Int)

Variables

Methods

clear():Void

forget(key:String):Void

ready(key:String):Bool

remainingMs(key:String):Int

tryUse(key:String):Bool