Moodle PHP Documentation 5.0
Moodle 5.0.1+ (Build: 20250711) (61af040cd5f)
core_ai\rate_limiter Class Reference

Public Member Functions

 __construct (private ClockInterface ClockInterface $clock,)
 Constructor.
 
 check_global_rate_limit (string $component, int $ratelimit)
 Check global rate limit for a component.
 
 check_user_rate_limit (string $component, int $ratelimit, int $userid)
 Check user rate limit for a component.
 

Public Attributes

int const TIME_WINDOW = HOURSECS
 TIME_WINDOW Time window in seconds (1 hour).
 

Constructor & Destructor Documentation

◆ __construct()

core_ai\rate_limiter::__construct ( private ClockInterface ClockInterface $clock)

Constructor.

Parameters
ClockInterface$clockClock instance for time management.
Parameters
$clockClock instance for time management.

Member Function Documentation

◆ check_global_rate_limit()

core_ai\rate_limiter::check_global_rate_limit ( string $component,
int $ratelimit )

Check global rate limit for a component.

Parameters
string$componentName of the component.
int$ratelimitNumber of requests per time window.
Return values
boolTrue if request is allowed, false otherwise.

◆ check_user_rate_limit()

core_ai\rate_limiter::check_user_rate_limit ( string $component,
int $ratelimit,
int $userid )

Check user rate limit for a component.

Parameters
string$componentName of the component.
int$ratelimitNumber of requests per time window.
int$useridUser ID for user-specific rate limit.
Return values
boolTrue if request is allowed, false otherwise.

The documentation for this class was generated from the following file: