Apc
Apc
APCu-backed cache backend implementation.
class Apc extends \Hazaar\Cache\BackendExtends: Hazaar\Cache\Backend
Provides 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 Hazaar\Cache\Backend\Apc::close.
Properties
weight
Backend priority weight used during backend selection.
protected int $weight = 1Type: int
refresh
private array $refreshType: array
Methods
available
Indicates whether the APCu backend is available in the current runtime.
public available(): boolReturns: bool
init
Initializes backend capabilities for APCu storage.
public init(string $namespace): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$namespace | string | active cache namespace |
close
Flushes deferred keepalive refresh entries.
public close(): boolReturns: bool
has
Checks whether a namespaced key exists in APCu.
public has(string $key, bool $checkEmpty): boolReturns: bool
Parameters
| 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): mixedReturns: mixed
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | cache key |
set
Stores a value in APCu with optional timeout.
public set(string $key, mixed $value, int $timeout): boolReturns: bool
Parameters
| 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): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | cache key |
clear
Clears the APCu user cache.
public clear(): boolReturns: bool
toArray
public toArray(): arrayReturns: array
count
Counts entries in the current namespace.
public count(): intReturns: int
key
Builds a fully-qualified namespaced cache key.
private key(string $key): stringReturns: string
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string | logical cache key |
Generated by Hazaar API Doc Generator on Fri, 04 Sep 2026 23:32:16 +0000