class RateLimitFilter extends ContentFilter (View source)

Provides rate limiting of execution of a callback

Traits

Provides extensions to this object to integrate it with standard config API methods.

Constants

CACHE_PREFIX

Cache key prefix

Config options

cache_lifetime int

Cache lifetime

from  ContentFilter
lock_timeout int

Time duration (in second) to allow for generation of cached results. Requests to pages that within this time period that do not hit the cache (and would otherwise trigger a version query) will be presented with a 429 (rate limit) HTTP error

lock_bypage bool

Determine if the cache generation should be locked on a per-page basis. If true, concurrent page versions may be generated without rate interference.

lock_byuserip bool

Determine if rate limiting should be applied independently to each IP address. This method is not reliable, as most DDoS attacks use multiple IP addresses.

lock_cooldown int

Time duration (in sections) to deny further search requests after a successful search.

Properties

protected ContentFilter $nestedContentFilter

Nested content filter

from  ContentFilter

Methods

public static 
config()

Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).

public
mixed
uninherited(string $name)

Gets the uninherited value for the given config option

public
__construct($nestedContentFilter = null)

No description

protected
CacheInterface
getCache()

Gets the cache to use

public
mixed
getContent(string $key, callable $callback)

Evaluates the result of the given callback

protected
string
getCacheKey(string $itemkey)

Determines the key to use for saving the current rate

Details

static Config_ForClass config()

Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).

Return Value

Config_ForClass

mixed uninherited(string $name)

Gets the uninherited value for the given config option

Parameters

string $name

Return Value

mixed

__construct($nestedContentFilter = null)

No description

Parameters

$nestedContentFilter

protected CacheInterface getCache()

Gets the cache to use

Return Value

CacheInterface

mixed getContent(string $key, callable $callback)

Evaluates the result of the given callback

Parameters

string $key

Unique key for this

callable $callback

Callback for evaluating the content

Return Value

mixed

Result of $callback()

protected string getCacheKey(string $itemkey)

Determines the key to use for saving the current rate

Parameters

string $itemkey

Input key

Return Value

string

Result key