class Memory extends Store implements IncrementDecrementInterface

Memory store.

Properties

protected string|null $prefix Prefix. from Store
protected array $cache Cache data.

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.

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

Fetch data from the cache and replace it. NULL will be returned if the item does not exist.

from Store
mixed
getAndRemove(string $key)

Fetch data from the cache and remove it. NULL will be returned if the item does not exist.

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.

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

Store data in the cache.

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

Increments a stored number.

false|int
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. NULL will be returned if the item does not exist.

bool
remove(string $key)

Delete data from the cache.

bool
clear()

Clears the cache.

Details

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

Sets the cache key prefix.

Parameters

string $prefix Prefix

Return Value

$this

in Store at line 40
string|null getPrefix()

Returns the cache key prefix.

Return Value

string|null

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

Returns a prefixed key.

Parameters

string $key Key

Return Value

string

in Store at line 59
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 77
mixed getAndPut(string $key, mixed $data, int $ttl = 0)

Fetch data from the cache and replace it. NULL will be returned if the item does not exist.

Parameters

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

Return Value

mixed

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

Fetch data from the cache and remove it. NULL will be returned if the item does not exist.

Parameters

string $key Cache key

Return Value

mixed

in Store at line 107
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 27
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 39
false|int increment(string $key, int $step = 1)

Increments a stored number.

Parameters

string $key Cache key
int $step Step

Return Value

false|int

at line 54
false|int decrement(string $key, int $step = 1)

Decrements a stored number.

Parameters

string $key Cache key
int $step Step

Return Value

false|int

at line 69
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 77
mixed get(string $key)

Fetch data from the cache. NULL will be returned if the item does not exist.

Parameters

string $key Cache key

Return Value

mixed

at line 95
bool remove(string $key)

Delete data from the cache.

Parameters

string $key Cache key

Return Value

bool

at line 110
bool clear()

Clears the cache.

Return Value

bool