class BoundedOrderedMap

internal  
 

Methods

__construct(int $capacity, callable|null $evictionCallback = null)

Create a bounded map with an optional eviction callback.

void
set(string $key, mixed $value)

Store a value, evicting the oldest entry when necessary.

mixed
get(string $key)

Return a value by key.

mixed
pull(string $key)

Remove and return a value by key.

newestFirst()

Yield entries from newest to oldest.

Details

at line 33
__construct(int $capacity, callable|null $evictionCallback = null)

Create a bounded map with an optional eviction callback.

Parameters

int $capacity
callable|null $evictionCallback

at line 47
void set(string $key, mixed $value)

Store a value, evicting the oldest entry when necessary.

Parameters

string $key
mixed $value

Return Value

void

at line 67
mixed get(string $key)

Return a value by key.

Parameters

string $key

Return Value

mixed

at line 77
mixed pull(string $key)

Remove and return a value by key.

Parameters

string $key

Return Value

mixed

at line 94
Generator newestFirst()

Yield entries from newest to oldest.

Return Value

Generator