Documentation

No matching pages.

API

Config

Facade

Lifecycle

Class: ArrayCache

Full name: Azera\Cache\ArrayCache

In-process cache backed by a PHP array.

Useful for development, testing, and short-lived processes. Values are stored with an expiry timestamp (or null for no expiry). No serialization overhead — values are kept as live references.

TTL handling:

  • int → seconds from now
  • DateInterval → added to now
  • null → no expiry (lives for the process lifetime)

Keys are validated to be non-empty, alphanumeric + ._-, max 64 chars.

Public methods

get() ·

public function get(string $key, mixed $default = null): mixed

Parameters

Name Type Default Description
$key string -
$default mixed null

Return value

  • Type: mixed

set() ·

public function set(string $key, mixed $value, DateInterval|int|null $ttl = null): bool

Parameters

Name Type Default Description
$key string -
$value mixed -
$ttl DateInterval|int|null null

Return value

  • Type: bool

delete() ·

public function delete(string $key): bool

Parameters

Name Type Default Description
$key string -

Return value

  • Type: bool

clear() ·

public function clear(): bool

Return value

  • Type: bool

getMultiple() ·

public function getMultiple(iterable $keys, mixed $default = null): iterable

Parameters

Name Type Default Description
$keys iterable -
$default mixed null

Return value

  • Type: iterable

setMultiple() ·

public function setMultiple(iterable $values, DateInterval|int|null $ttl = null): bool

Parameters

Name Type Default Description
$values iterable -
$ttl DateInterval|int|null null

Return value

  • Type: bool

deleteMultiple() ·

public function deleteMultiple(iterable $keys): bool

Parameters

Name Type Default Description
$keys iterable -

Return value

  • Type: bool

has() ·

public function has(string $key): bool

Parameters

Name Type Default Description
$key string -

Return value

  • Type: bool

gc() ·

public function gc(): void

Remove all expired entries. Called opportunistically; not required for correctness since expired entries are lazily purged on access.

Return value

  • Type: void

Back to the Index