Liking cljdoc? Tell your friends :D

kilderkin.core

Immutable data structures for efficient rate limiting.

Immutable data structures for efficient rate limiting.
raw docstring

allow-now?clj/s

(allow-now? rate-limiter k)

Checks whether the key k is allowed now or should be rate-limited.

Checks whether the key `k` is allowed now or should be rate-limited.
raw docstring

CachingRateLimiterclj/sprotocol

Protocol for rate limiters that can cache data for missed entries.

Protocol for rate limiters that can cache data for missed entries.

allow?clj/s

(allow? this k ts)

Checks whether the key k is allowed at time ts or should be rate-limited.

Checks whether the key `k` is allowed at time `ts` or should be
rate-limited.

drop-expiredclj/s

(drop-expired this ts)

Updates the rate limiter such that the state for all keys that are expired at ts are removed.

Updates the rate limiter such that the state for all keys that are expired
at `ts` are removed.

get-cachedclj/s

(get-cached this k)

Gets the cached value for k, if one exists.

Gets the cached value for `k`, if one exists.

insertclj/s

(insert this k ts)
(insert this k ts v)

Updates the rate limiter with key k at time ts. If v is provided, it's cached if and only if k is not allowed.

Updates the rate limiter with key `k` at time `ts`. If `v` is provided, it's
cached if and only if `k` is not allowed.

insert-allow?clj/s

(insert-allow? this k ts)
(insert-allow? this k ts v)

Updates the rate limiter with key k at time ts. If v is provided, it's cached if and only if k is not allowed.

Returns a triple containing:

  1. The modified rate limiter.
  2. A flag saying if the key should be allowed (true) or rate-limited (false).
  3. The previously cached value for k, if it exists and is dropped by the   insert operation (this happens when the previous insert for k was   rate-limited and a value was provided for caching).

This fn is really just a more convenient/efficient way to run:

[(insert this k ts v)
 (allow? this k ts)
 (if (allow? this k ts) (get-cached this k))]
Updates the rate limiter with key `k` at time `ts`. If `v` is provided, it's
cached if and only if `k` is not allowed.

Returns a triple containing:
1. The modified rate limiter.
2. A flag saying if the key should be allowed (true) or rate-limited (false).
3. The previously cached value for `k`, if it exists and is dropped by the
   insert operation (this happens when the previous insert for `k` was
   rate-limited and a value was provided for caching).

This fn is really just a more convenient/efficient way to run:
```
[(insert this k ts v)
 (allow? this k ts)
 (if (allow? this k ts) (get-cached this k))]
```

take-expiredclj/s

(take-expired this ts)

Returns a sequence of all cached values that would be expired at ts, as key-value pairs.

Returns a sequence of all cached values that would be expired at `ts`, as
key-value pairs.
raw docstring

default-configclj/s

The default config values for new rate limiters.

The default config values for new rate limiters.
raw docstring

drop-expired-nowclj/s

(drop-expired-now rate-limiter)

Updates the rate limiter such that the state for all keys that are currently expired are removed.

Updates the rate limiter such that the state for all keys that are currently
expired are removed.
raw docstring

HoppingWindowRateLimiterclj/s


insert!clj/s

(insert! *rl k ts)
(insert! *rl k ts v)

Inserts k into *rl at time ts. If v is provided, it is cached (if k is rate-limited).

Inserts `k` into `*rl` at time `ts`. If `v` is provided, it is cached (if
`k` is rate-limited).
raw docstring

insert-allow?!clj/s

(insert-allow?! *rl k ts)
(insert-allow?! *rl k ts v)

Inserts k into *rl at time ts. If v is provided, it is cached (if k is rate-limited). Returns whether the key is allowed or should be rate-limited.

Inserts `k` into `*rl` at time `ts`. If `v` is provided, it is cached (if `k`
is rate-limited).
Returns whether the key is allowed or should be rate-limited.
raw docstring

insert-allow?-nowclj/s

(insert-allow?-now rate-limiter k)
(insert-allow?-now rate-limiter k v)

Updates the rate limiter with key k at the current timestamp. If v is provided, it's cached if and only if k is not allowed.

Returns a triple containing:

  1. The modified rate limiter.
  2. A flag saying if the key should be allowed (true) or rate-limited (false).
  3. The previously cached value for k, if it exists and is dropped by the   insert operation (this happens when the previous insert for k was   rate-limited and a value was provided for caching).

This fn is really just a more convenient/efficient way to run:

(let [allow? (allow-now? this k ts)]
  [(insert-now this k ts v) allow? (if allow? (get-cached this k))])
Updates the rate limiter with key `k` at the current timestamp. If `v` is
provided, it's cached if and only if `k` is not allowed.

Returns a triple containing:
1. The modified rate limiter.
2. A flag saying if the key should be allowed (true) or rate-limited (false).
3. The previously cached value for `k`, if it exists and is dropped by the
   insert operation (this happens when the previous insert for `k` was
   rate-limited and a value was provided for caching).

This fn is really just a more convenient/efficient way to run:
```
(let [allow? (allow-now? this k ts)]
  [(insert-now this k ts v) allow? (if allow? (get-cached this k))])
```
raw docstring

insert-allow?-now!clj/s

(insert-allow?-now! *rl k)
(insert-allow?-now! *rl k v)

Inserts k into *rl at the current timestamp. If v is provided, it is cached (if k is rate-limited). Returns whether the key is allowed or should be rate-limited.

Inserts `k` into `*rl` at the current timestamp. If `v` is provided, it is
cached (if `k` is rate-limited).
Returns whether the key is allowed or should be rate-limited.
raw docstring

insert-nowclj/s

(insert-now rate-limiter k)
(insert-now rate-limiter k v)

Updates the rate limiter with key k at time ts. If v is provided, it's cached if and only if k is not allowed.

Updates the rate limiter with key `k` at time `ts`. If `v` is provided, it's
cached if and only if `k` is not allowed.
raw docstring

insert-now!clj/s

(insert-now! *rl k)
(insert-now! *rl k v)

Inserts k into *rl at the current timestamp. If v is provided and k gets rate-limited, v gets cached.

Inserts `k` into `*rl` at the current timestamp. If `v` is provided and `k`
gets rate-limited, `v` gets cached.
raw docstring

rate-limiterclj/s

(rate-limiter config)

Builds a rate-limiter from the provided configuration.

Builds a rate-limiter from the provided configuration.
raw docstring

SlidingWindowRateLimiterclj/s


take-expired-nowclj/s

(take-expired-now rate-limiter)

Returns a sequence of all cached values that are currently expired, as key-value pairs.

Returns a sequence of all cached values that are currently expired, as
key-value pairs.
raw docstring

truncate!clj/s

(truncate! *rl ts)

Removes and returns all keys in *rl that are expired at time ts.

Removes and returns all keys in `*rl` that are expired at time `ts`.
raw docstring

truncate-now!clj/s

(truncate-now! *rl)

Removes all keys in *rl that are expired at the current time. Returns a list of key-value pairs

Removes all keys in `*rl` that are expired at the current time. Returns a
list of key-value pairs 
raw docstring

TumblingWindowRateLimiterclj/s

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close