class Frequency implements FrequencyInterface, LowFrequencyInterface

Tracks connection frequency to enable low-frequency pool flushing.

Records hits over a time window and calculates average frequency to determine if the pool is in low-frequency mode.

Properties

protected array<int, int> $hits

Hit counts by timestamp.

protected int $time

Time window in seconds for frequency calculation.

protected int $lowFrequency

Threshold below which frequency is considered "low".

protected int $beginTime

Time when frequency tracking began.

protected int $lowFrequencyTime

Last time low frequency was triggered.

protected int $lowFrequencyInterval

Minimum interval between low frequency triggers.

Methods

__construct()

No description

bool
hit(int $number = 1)

Record a hit.

float
frequency()

Calculate the average frequency over the time window.

bool
isLowFrequency()

Check if currently in low frequency mode.

void
flush()

Flush old hits outside the time window.

Details

at line 49
__construct()

No description

at line 58
bool hit(int $number = 1)

Record a hit.

Parameters

int $number

Return Value

bool

at line 72
float frequency()

Calculate the average frequency over the time window.

Return Value

float

at line 88
bool isLowFrequency()

Check if currently in low frequency mode.

Return Value

bool

at line 104
protected void flush()

Flush old hits outside the time window.

Return Value

void