Shm
Shm
The PHP-SHM (shared memory) cache backend.
This is the absolute fastest caching backend.
There are no configuration options required for the backend.
Constants
GC_KEY
const GC_KEY = __garbage_collection__
Properties
weight
protected int $weight
public $
public $
keepalive
private bool $keepalive
indexKey
private int $indexKey
locks
private array $locks
Methods
available
public available({Array})
init
Initializes the shared memory cache backend for a given namespace.
public init({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$namespace | string | the namespace for the cache backend |
close
Closes the shared memory cache.
public close({Array})
has
Check if a key exists in the shared memory cache.
public has({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$key | string | the key to check |
$check_empty | bool | whether to check if the data associated with the key is empty |
get
Retrieves the value associated with the given key from the cache.
public get({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$key | string | the key to retrieve the value for |
set
Sets a value in the shared memory cache.
public set({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$key | string | the key to store the value under |
$value | mixed | the value to be stored |
$timeout | int | The timeout for the value in seconds. Default is 0 (no timeout). |
remove
Remove a value from the shared memory cache.
public remove({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$key | string | the key of the value to remove |
clear
Clears the shared memory cache.
public clear({Array})
toArray
Converts the cache data to an array.
public toArray({Array})
count
Returns the number of items in the cache.
public count({Array})
lock
Locks a cache entry for exclusive access.
public lock({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$key | string | the key of the cache entry |
unlock
Unlock a lock for a given key.
public unlock({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$key | string | the key of the lock to unlock |
findFirstAvailableAddress
private findFirstAvailableAddress({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$index | array |
getIndex
Retrieves the index from the shared memory.
private getIndex({Array})
getAddr
Retrieves the address of a key in the cache.
private getAddr({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$key | string | the key to retrieve the address for |
$create | bool | whether to create the key if it doesn't exist |
addIndex
Adds an index for the given key in the shared memory cache backend.
private addIndex({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$key | string | the key to add an index for |
removeIndex
Remove an entry from the cache index.
private removeIndex({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$key | string | the key of the entry to be removed |
infoByAddr
Retrieves information stored in shared memory by address.
private infoByAddr({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$addr | int | the address of the shared memory variable |
$noKeepalive | bool | |
$ | bool |
infoByKey
Retrieves information about a cache entry by its key.
private infoByKey({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$key | string | the key of the cache entry |
$ | bool |
Generated by Hazaar API Doc Generator