Elgg  Version 5.1
Public Member Functions | Protected Attributes | List of all members
Elgg\Cache\QueryCache Class Reference

Volatile cache for select queries. More...

Inheritance diagram for Elgg\Cache\QueryCache:
Elgg\Cache\LRUCache

Public Member Functions

 __construct (int $size=50, bool $config_disabled=false)
 
 enable ()
 Enable the query cache. More...
 
 disable (bool $clear=true)
 Disable the query cache. More...
 
 isEnabled ()
 Checks if this cache is enabled. More...
 
 clear ()
 
 get ($key, $default=null)
 
 set ($key, $value)
 
 getHash (string $sql, array $params=[], string $extras= '')
 Returns a hashed key for storage in the cache. More...
 
- Public Member Functions inherited from Elgg\Cache\LRUCache
 __construct (int $size)
 Create a LRU Cache. More...
 
 get ($key, $default=null)
 Get the value cached with this key. More...
 
 set ($key, $value)
 Add something to the cache. More...
 
 size ()
 Get the number of elements in the cache. More...
 
 containsKey ($key)
 Does the cache contain an element with this key. More...
 
 remove ($key)
 Remove the element with this key. More...
 
 clear ()
 Clear the cache. More...
 
 offsetSet ($offset, $value)
 Assigns a value for the specified key. More...
 
 offsetGet ($offset)
 Get the value for specified key. More...
 
 offsetUnset ($offset)
 Unsets a key. More...
 
 offsetExists ($offset)
 Does key exist? More...
 

Protected Attributes

 $config_disabled = false
 
 $runtime_enabled = false
 
- Protected Attributes inherited from Elgg\Cache\LRUCache
 $maximumSize
 
 $data = []
 

Additional Inherited Members

- Protected Member Functions inherited from Elgg\Cache\LRUCache
 recordAccess ($key)
 Moves the element from current position to end of array. More...
 

Detailed Description

Volatile cache for select queries.

Queries and their results are stored in this cache as: $DB_QUERY_CACHE[query hash] => array(result1, result2, ... resultN)

Definition at line 17 of file QueryCache.php.

Constructor & Destructor Documentation

Elgg\Cache\QueryCache::__construct ( int  $size = 50,
bool  $config_disabled = false 
)

Parameters
int$sizemax items in LRU cache
bool$config_disabledis this cache allowed to be used

Definition at line 37 of file QueryCache.php.

Member Function Documentation

Elgg\Cache\QueryCache::clear ( )

Definition at line 89 of file QueryCache.php.

Elgg\Cache\QueryCache::disable ( bool  $clear = true)

Disable the query cache.

This is useful for special scripts that pull large amounts of data back in single queries.

Parameters
bool$clearalso clear the cache (default: true)
Returns
void

Definition at line 65 of file QueryCache.php.

Elgg\Cache\QueryCache::enable ( )

Enable the query cache.

This does not take precedence over the setting.

Returns
void

Definition at line 51 of file QueryCache.php.

Elgg\Cache\QueryCache::get (   $key,
  $default = null 
)

Definition at line 98 of file QueryCache.php.

Elgg\Cache\QueryCache::getHash ( string  $sql,
array  $params = [],
string  $extras = '' 
)

Returns a hashed key for storage in the cache.

Parameters
string$sqlquery
array$paramsoptional params
string$extrasoptional extras
Returns
string

Definition at line 132 of file QueryCache.php.

Elgg\Cache\QueryCache::isEnabled ( )

Checks if this cache is enabled.

Returns
boolean

Definition at line 78 of file QueryCache.php.

Elgg\Cache\QueryCache::set (   $key,
  $value 
)

Definition at line 113 of file QueryCache.php.

Member Data Documentation

Elgg\Cache\QueryCache::$config_disabled = false
protected

Definition at line 24 of file QueryCache.php.

Elgg\Cache\QueryCache::$runtime_enabled = false
protected

Definition at line 29 of file QueryCache.php.


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