BorrowRateTracker
class BorrowRateTracker implements UsageTracker
Track recent borrowing activity to shrink pools during periods of low usage.
Properties
| protected array<int, int> | $borrows | ||
| protected int | $window | ||
| protected int | $threshold | ||
| protected int | $cooldown | ||
| protected int|null | $startedAt | ||
| protected int|null | $lastTrimAt | ||
| protected int|null | $lastPrunedAt | ||
| protected int | $borrowCount |
Methods
void
recordBorrow()
Record a successful connection borrow.
float
getBorrowRate()
Return the average number of borrows per sampled second.
bool
shouldTrimExcessIdle()
Determine whether low usage and the cooldown permit trimming.
void
prune(int $now)
Remove expired samples and fill completed seconds without borrows.
int
currentTime()
Return the current sampling second.
Details
at line 36
void
recordBorrow()
Record a successful connection borrow.
at line 53
float
getBorrowRate()
Return the average number of borrows per sampled second.
at line 68
bool
shouldTrimExcessIdle()
Determine whether low usage and the cooldown permit trimming.
at line 95
protected void
prune(int $now)
Remove expired samples and fill completed seconds without borrows.
at line 120
protected int
currentTime()
Return the current sampling second.