SilverStripe\VersionFeed\Filters\RateLimitFilter
Provides rate limiting of execution of a callback
Synopsis
class RateLimitFilter
extends ContentFilter
{
- // constants
- const CACHE_PREFIX = 'RateLimitBegin';
- // members
- private static integer $lock_timeout = 5;
- private static bool $lock_bypage = false;
- private static bool $lock_byuserip = false;
- private static integer $lock_cooldown = 2;
- // Inherited members from ContentFilter
- protected ContentFilter $nestedContentFilter;
- // methods
- protected string getCacheKey()
- public void getContent()
- // Inherited methods from ContentFilter
- public void __construct()
- protected CacheInterface getCache()
- public mixed getContent()
Hierarchy
Constants
Name | Value |
---|---|
CACHE_PREFIX | 'RateLimitBegin' |
Members
private
- $lock_bypage
—
SilverStripe\VersionFeed\Filters\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
—
SilverStripe\VersionFeed\Filters\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. - $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
protected
- $nestedContentFilter
—
SilverStripe\VersionFeed\Filters\ContentFilter
Nested content filter
Methods
protected
- getCacheKey() — Determines the key to use for saving the current rate
public
Inherited from SilverStripe\VersionFeed\Filters\ContentFilter
protected
- getCache() — Gets the cache to use
public
- getContent() — Evaluates the result of the given callback