Apc
Apc
APCu-backed cache backend implementation.
class Apc extends \Hazaar\Cache\Backend\BackendProvides high-performance in-memory cache storage using the APCu extension. Keys are namespaced using the backend namespace to isolate entries between cache contexts.
This backend advertises object storage, TTL, array export, namespace expiry, value expiry, and keepalive capabilities. Keepalive behavior is implemented by deferring key refresh writes until {@see self::close()}.
Properties
weight
Backend priority weight used during backend selection.
protected int $weight = 1refresh
private array $refreshMethods
available
Indicates whether the APCu backend is available in the current runtime.
public available(): boolinit
Initializes backend capabilities for APCu storage.
public init(string $namespace): voidParameters
| Parameter | Type | Description |
|---|---|---|
$namespace | string | active cache namespace |
close
Flushes deferred keepalive refresh entries.
public close(): boolhas
Checks whether a namespaced key exists in APCu.
public has(string $key, bool $checkEmpty): boolParameters
| Parameter | Type | Description |
|---|---|---|
$key | string | cache key |
$checkEmpty | bool | whether to treat empty values as missing |
get
Retrieves a value from APCu by namespaced key.
public get(string $key): mixedParameters
| Parameter | Type | Description |
|---|---|---|
$key | string | cache key |
set
Stores a value in APCu with optional timeout.
public set(string $key, mixed $value, int $timeout): boolParameters
| Parameter | Type | Description |
|---|---|---|
$key | string | cache key |
$value | mixed | value to store |
$timeout | int | TTL in seconds; falls back to backend default when zero |
remove
Removes a namespaced key from APCu.
public remove(string $key): boolParameters
| Parameter | Type | Description |
|---|---|---|
$key | string | cache key |
clear
Clears the APCu user cache.
public clear(): booltoArray
public toArray(): voidcount
Counts entries in the current namespace.
public count(): intkey
Builds a fully-qualified namespaced cache key.
private key(string $key): stringParameters
| Parameter | Type | Description |
|---|---|---|
$key | string | logical cache key |
Generated by Hazaar API Doc Generator on Tue, 21 Apr 2026 04:00:25 +0000