StormCache
An advanced library to extend and handle PECL-Memcached.
Loading...
Searching...
No Matches
StormCache Class Reference

Public Member Functions

 AddPool ($name)
 
 AddPoolServer ($serverIP, $serverPORT, $serverWEIGHT, $poolNAME=self::DefaultPoolName)
 
 Get ($key, &$data, $poolNAME=self::DefaultPoolName)
 
 Set ($key, $data, $namespaces=NULL, $expire=StormCachePool::DefaultCacheExpiryTime, $poolNAME=self::DefaultPoolName)
 
 SetMulti ($items, $expire=StormCachePool::DefaultCacheExpiryTime, $poolNAME=self::DefaultPoolName)
 
 Replace ($key, $data, $expire=StormCachePool::DefaultCacheExpiryTime, $poolNAME=self::DefaultPoolName)
 
 SetReplace ($key, $data, $namespaces=NULL, $expire=StormCachePool::DefaultCacheExpiryTime, $poolNAME=self::DefaultPoolName)
 
 ExpireNamespace ($namespaces, $poolNAME=self::DefaultPoolName)
 
 Flush ($poolNAME=self::DefaultPoolName)
 
 Delete ($key, $poolNAME=self::DefaultPoolName)
 
 DeleteMulti ($keys, $poolNAME=self::DefaultPoolName)
 
 Touch ($key, $expire=StormCachePool::DefaultCacheExpiryTime, $poolNAME=self::DefaultPoolName)
 
 TouchMulti ($keys, $expire=StormCachePool::DefaultCacheExpiryTime, $poolNAME=self::DefaultPoolName)
 
 GetStats ($poolNAME=self::DefaultPoolName)
 
 GetHits ($poolNAME=self::DefaultPoolName)
 
 GetMisses ($poolNAME=self::DefaultPoolName)
 
 IsEnabled ()
 
 SetEncryptionCredentials ($password)
 
 IsEncryptionEnabled ()
 

Static Public Member Functions

static GetInstance ()
 

Public Attributes

const DefaultPoolName = "default"
 

Member Function Documentation

◆ AddPool()

StormCache::AddPool (   $name)

Adds a new pool.

Parameters
string$nameThe name of the pool.
Exceptions
PoolNameConflictIf a pool with the same name already exists.

◆ AddPoolServer()

StormCache::AddPoolServer (   $serverIP,
  $serverPORT,
  $serverWEIGHT,
  $poolNAME = self::DefaultPoolName 
)

Adds a Memcached server to a pool.

Parameters
string$serverIPThe server's IP address.
int$serverPORTThe server's port.
int$serverWEIGHTThe weight of the server relative to others in the pool.
string$poolNAMEThe name of the pool (default is "default").
Exceptions
PoolNotFoundIf the specified pool does not exist.

◆ Delete()

StormCache::Delete (   $key,
  $poolNAME = self::DefaultPoolName 
)

Deletes a stored key data

Parameters
string$key
string$poolNAMEPool Name (if not specified, default pool is selected)
Returns
bool Operation Status

◆ DeleteMulti()

StormCache::DeleteMulti (   $keys,
  $poolNAME = self::DefaultPoolName 
)

Deletes multiple items in cache

Parameters
string[]$keysKeys to delete
string$poolNAMEPool Name (if not specified, default pool is selected)
Returns
bool Operation Status

◆ ExpireNamespace()

StormCache::ExpireNamespace (   $namespaces,
  $poolNAME = self::DefaultPoolName 
)

Expires namespaces

Parameters
string | array$namespaces
string$poolNAMEPool Name (if not specified, default pool is selected)

◆ Flush()

StormCache::Flush (   $poolNAME = self::DefaultPoolName)

Flush all data from cache

Parameters
string | array | NULL$poolNAMEPool Name to flush data from (NULL to flush all)

◆ Get()

StormCache::Get (   $key,
$data,
  $poolNAME = self::DefaultPoolName 
)

Retrieves data from the cache.

Parameters
string$keyThe key to retrieve.
mixed&$dataReference variable to store the retrieved data.
string$poolNAMEThe name of the pool (default is "default").
Exceptions
CacheNotEnabledIf caching is not enabled (no servers added to any pool).
PoolNotFoundIf the specified pool does not exist.
PoolNoServersConfiguredIf the selected pool has no servers configured.
PoolItemNotFoundIf the item is not found in the cache.
PoolItemNotEncryptedIf the item is not encrypted but encryption is enabled.
PoolItemDecryptFailedIf decryption of the item fails.
PoolItemEncryptedIf the item is encrypted but encryption is disabled.

◆ GetHits()

StormCache::GetHits (   $poolNAME = self::DefaultPoolName)

Gets cache hits

Parameters
string | NULL$poolNAMEPool Name (if not specified, all pools are selected)
Returns
int

◆ GetInstance()

static StormCache::GetInstance ( )
static

Gets the singleton instance of StormCache.

Returns
StormCache The singleton instance.

◆ GetMisses()

StormCache::GetMisses (   $poolNAME = self::DefaultPoolName)

Gets cache misses

Parameters
string | NULL$poolNAMEPool Name (if not specified, all pools are selected)
Returns
int

◆ GetStats()

StormCache::GetStats (   $poolNAME = self::DefaultPoolName)

Gets pool stats

Parameters
string$poolNAMEPool Name (if not specified, default pool is selected)
string | NULL$poolNAMEPool Name (if not specified, all pools are selected)
Returns
array|null

◆ IsEnabled()

StormCache::IsEnabled ( )

Is Cache enabled? (If it has no servers, then it is not enabled)

Returns
bool

◆ IsEncryptionEnabled()

StormCache::IsEncryptionEnabled ( )

Is encryption enabled?

Returns
bool

◆ Replace()

StormCache::Replace (   $key,
  $data,
  $expire = StormCachePool::DefaultCacheExpiryTime,
  $poolNAME = self::DefaultPoolName 
)

Replaces data in cache

Parameters
string$keyKey
mixed$dataData to store
int$expireExpire time seconds if less than 30 days or timestamp if it is greater
string$poolNAMEPool Name (if not specified, default pool is selected)

◆ Set()

StormCache::Set (   $key,
  $data,
  $namespaces = NULL,
  $expire = StormCachePool::DefaultCacheExpiryTime,
  $poolNAME = self::DefaultPoolName 
)

Stores data in the cache.

Parameters
string$keyThe key to store the data under.
mixed$dataThe data to store.
string | array | null$namespacesThe namespace(s) to bind the data to (optional).
int$expireExpiration time in seconds (or timestamp if greater than 30 days).
string$poolNAMEThe name of the pool (default is "default").
Returns
bool True if the operation was successful, false otherwise.

◆ SetEncryptionCredentials()

StormCache::SetEncryptionCredentials (   $password)

Set encryption password (and implicitelly enable encryption features)

Parameters
string$passwordPassword for encrypting

◆ SetMulti()

StormCache::SetMulti (   $items,
  $expire = StormCachePool::DefaultCacheExpiryTime,
  $poolNAME = self::DefaultPoolName 
)

Sets multiple data at once (SetMulti do NOT support namespace currently)

Parameters
array$itemsItems to be added in the form key => data (do NOT store boolean false in data)
int$expireExpire time seconds if less than 30 days or timestamp if it is greater
string$poolNAMEPool Name (if not specified, default pool is selected)
Returns
bool Operation Status

◆ SetReplace()

StormCache::SetReplace (   $key,
  $data,
  $namespaces = NULL,
  $expire = StormCachePool::DefaultCacheExpiryTime,
  $poolNAME = self::DefaultPoolName 
)

Sets or replace data (it does not throw any exception to improve code quality when using the lib)

Since
3.1.1
Parameters
string$keyKey Key to store data in server
mixed$dataData Data to store (do NOT store a boolean FALSE, because it will be stored but appear as failed when get)
string | array | NULL$namespacesNamespace to bind data to (if applicable)
int$expireExpire time seconds if less than 30 days or timestamp if it is greater
string$poolNAMEPool Name (if not specified, default pool is selected)
Returns
bool Operation Status

◆ Touch()

StormCache::Touch (   $key,
  $expire = StormCachePool::DefaultCacheExpiryTime,
  $poolNAME = self::DefaultPoolName 
)

Touch data (sets new expiration time)

Parameters
string$keyKey to be affected
int$expireExpire time seconds if less than 30 days or timestamp if it is greater
string$poolNAMEPool Name (if not specified, default pool is selected)
Returns
bool Operation Status

◆ TouchMulti()

StormCache::TouchMulti (   $keys,
  $expire = StormCachePool::DefaultCacheExpiryTime,
  $poolNAME = self::DefaultPoolName 
)

Touch multiple data (sets new expiration time)

Parameters
string[]$keysKeys to be affected
int$expireExpire time seconds if less than 30 days or timestamp if it is greater
string$poolNAMEPool Name (if not specified, default pool is selected)
Returns
bool Operation Status

The documentation for this class was generated from the following file: