opsdash-app/opsdash/tests/php/stubs/OCP/ICacheFactory.php
blade34242 ea2237e3fd security: rate limit /loadData to 5 req/10 s per user via ICacheFactory
Adds LoadRateLimiter with a two-layer check: 2-second minimum interval
between requests, and a burst cap of 5 per 10-second window. Uses the
distributed cache (Redis/APCu) so the limit applies across workers.
Fails open when cache is unavailable so a cold cache never blocks users.
Returns 429 Too Many Requests when throttled.

Also updates ICacheFactory stub and FakeCacheFactory implementations to
match the full interface (isAvailable, createDistributed, createInMemory).
2026-05-06 13:59:12 +07:00

13 lines
349 B
PHP

<?php
declare(strict_types=1);
namespace OCP;
interface ICacheFactory {
public function isAvailable(): bool;
public function isLocalCacheAvailable(): bool;
public function createLocal(string $prefix = ''): ICache;
public function createDistributed(string $prefix = ''): ICache;
public function createInMemory(int $capacity = 512): ICache;
}