class Memcache extends Store

Memcache store.

Properties

protected string|null $prefix Prefix. from Store
protected Memcache $memcache Memcache instance.
protected int $compressionLevel Compression level.

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. 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
__construct(array $servers, int $timeout = 1, bool $compressData = false)

Constructor.

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

Store data in the cache.

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

at line 80
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 40
__construct(array $servers, int $timeout = 1, bool $compressData = false)

Constructor.

Parameters

array $servers Memcache servers
int $timeout Timeout in seconds
bool $compressData Compress data?

at line 60
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 93
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 101
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 113
bool remove(string $key)

Delete data from the cache.

Parameters

string $key Cache key

Return Value

bool

at line 121
bool clear()

Clears the cache.

Return Value

bool