MemoryBackend
class MemoryBackend implements FloodInterface (View source)
Defines the memory flood backend. This is used for testing.
Properties
| protected RequestStack | $requestStack | The request stack. |
|
| protected | $events | An array holding flood events, keyed by event name and identifier. |
Methods
Construct the MemoryBackend.
Registers an event for the current visitor to the flood control mechanism.
Makes the flood control mechanism forget an event for the current visitor.
Checks whether a user is allowed to proceed with the specified event.
Cleans up expired flood events. This method is called automatically on cron run.
Details
__construct(RequestStack $request_stack)
Construct the MemoryBackend.
register(string $name, int $window = 3600, string $identifier = NULL)
Registers an event for the current visitor to the flood control mechanism.
clear(string $name, string $identifier = NULL)
Makes the flood control mechanism forget an event for the current visitor.
true
isAllowed(string $name, int $threshold, int $window = 3600, string $identifier = NULL)
Checks whether a user is allowed to proceed with the specified event.
Events can have thresholds saying that each user can only do that event a certain number of times in a time window. This function verifies that the current user has not exceeded this threshold.
garbageCollection()
Cleans up expired flood events. This method is called automatically on cron run.