class APCU extends Store implements IncrementDecrementInterface

APCU store.

Properties

protected string|null $prefix Prefix. from Store
protected bool $atomicGetOrElse Whether to use atomic updates for getOrElse.

Methods

$this
setPrefix(string $prefix)

Sets the cache key prefix.

from Store
string|null
getPrefix()

Returns the cache key prefix.

from Store
string
getPrefixedKey(string $key)

Returns a prefixed key.

from Store
bool
putIfNotExists(string $key, mixed $data, int $ttl = 0)

Store data in the cache if it doesn't already exist.

mixed
getAndPut(string $key, mixed $data, int $ttl = 0)

Fetch data from the cache and replace it.

from Store
mixed
getAndRemove(string $key)

Fetch data from the cache and remove it.

from Store
mixed
getOrElse(string $key, callable $data, int $ttl = 0)

Fetch data from the cache or store it if it doesn't already exist.

__construct()

Constructor.

useAtomicGetOrElse(bool $toUse)

Set whether to use atomic get/set for getOrElse.

bool
put(string $key, mixed $data, int $ttl = 0)

Store data in the cache.

int|bool
increment(string $key, int $step = 1)

Increments a stored number.

int|bool
decrement(string $key, int $step = 1)

Decrements a stored number.

bool
has(string $key)

Returns TRUE if the cache key exists and FALSE if not.

mixed
get(string $key)

Fetch data from the cache.

bool
remove(string $key)

Delete data from the cache.

bool
clear()

Clears the cache.

Details

in Store at line 30
$this setPrefix(string $prefix)

Sets the cache key prefix.

Parameters

string $prefix Prefix

Return Value

$this

in Store at line 42
string|null getPrefix()

Returns the cache key prefix.

Return Value

string|null

in Store at line 53
protected string getPrefixedKey(string $key)

Returns a prefixed key.

Parameters

string $key Key

Return Value

string

at line 77
bool putIfNotExists(string $key, mixed $data, int $ttl = 0)

Store data in the cache if it doesn't already exist.

Parameters

string $key Cache key
mixed $data The data to store
int $ttl Time to live

Return Value

bool

in Store at line 79
mixed getAndPut(string $key, mixed $data, int $ttl = 0)

Fetch data from the cache and replace it.

Parameters

string $key Cache key
mixed $data The data to store
int $ttl Time to live

Return Value

mixed

in Store at line 94
mixed getAndRemove(string $key)

Fetch data from the cache and remove it.

Parameters

string $key Cache key

Return Value

mixed

at line 117
mixed getOrElse(string $key, callable $data, int $ttl = 0)

Fetch data from the cache or store it if it doesn't already exist.

Parameters

string $key Cache key
callable $data
int $ttl Time to live

Return Value

mixed

at line 45
__construct()

Constructor.

Exceptions

RuntimeException

at line 59
APCU useAtomicGetOrElse(bool $toUse)

Set whether to use atomic get/set for getOrElse.

Parameters

bool $toUse the new state.

Return Value

APCU

at line 69
bool put(string $key, mixed $data, int $ttl = 0)

Store data in the cache.

Parameters

string $key Cache key
mixed $data The data to store
int $ttl Time to live

Return Value

bool

at line 85
int|bool increment(string $key, int $step = 1)

Increments a stored number.

Parameters

string $key Cache key
int $step Step

Return Value

int|bool

at line 93
int|bool decrement(string $key, int $step = 1)

Decrements a stored number.

Parameters

string $key Cache key
int $step Step

Return Value

int|bool

at line 101
bool has(string $key)

Returns TRUE if the cache key exists and FALSE if not.

Parameters

string $key Cache key

Return Value

bool

at line 109
mixed get(string $key)

Fetch data from the cache.

Parameters

string $key Cache key

Return Value

mixed

at line 130
bool remove(string $key)

Delete data from the cache.

Parameters

string $key Cache key

Return Value

bool

at line 138
bool clear()

Clears the cache.

Return Value

bool