The library file for the static cache store. This file is part of the static cache store, it contains the API for interacting with an instance of the store. This is used as a default cache store within the Cache API. It should never be deleted.
Copyright: | 2012 Sam Hemelryk |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 578 lines (17 kb) |
Included or required: | 1 time |
Referenced: | 1 time |
Includes or requires: | 0 files |
static_data_store:: (3 methods):
register_store_id()
flush_store_by_id()
flush_store()
cachestore_static:: (28 methods):
__construct()
get_supported_features()
supports_multiple_identifiers()
get_supported_modes()
are_requirements_met()
is_supported_mode()
initialise()
is_initialised()
serialize()
unserialize()
get()
get_many()
set()
set_many()
has()
has_all()
has_any()
delete()
delete_many()
purge()
reduce_for_maxsize()
can_add_instance()
instance_deleted()
initialise_test_instance()
unit_test_configuration()
my_name()
find_all()
find_by_prefix()
Class: static_data_store - X-Ref
The static data store classregister_store_id($id) X-Ref |
Returns a static store by reference... REFERENCE SUPER IMPORTANT. param: string $id return: array |
flush_store_by_id($id) X-Ref |
Flushes the store of all values for belonging to the store with the given id. param: string $id |
flush_store() X-Ref |
Flushes all of the values from all stores. |
Class: cachestore_static - X-Ref
The static store class.__construct($name, array $configuration = array() X-Ref |
Constructs the store instance. Noting that this function is not an initialisation. It is used to prepare the store for use. The store will be initialised when required and will be provided with a cache_definition at that time. param: string $name param: array $configuration |
get_supported_features(array $configuration = array() X-Ref |
Returns the supported features as a combined int. param: array $configuration return: int |
supports_multiple_identifiers() X-Ref |
Returns true as this store does support multiple identifiers. (This optional function is a performance optimisation; it must be consistent with the value from get_supported_features.) return: bool true |
get_supported_modes(array $configuration = array() X-Ref |
Returns the supported modes as a combined int. param: array $configuration return: int |
are_requirements_met() X-Ref |
Returns true if the store requirements are met. return: bool |
is_supported_mode($mode) X-Ref |
Returns true if the given mode is supported by this store. param: int $mode One of cache_store::MODE_* return: bool |
initialise(cache_definition $definition) X-Ref |
Initialises the cache. Once this has been done the cache is all set to be used. param: cache_definition $definition |
is_initialised() X-Ref |
Returns true once this instance has been initialised. return: bool |
serialize($data) X-Ref |
Uses igbinary serializer if igbinary extension is loaded. Fallback to PHP serializer. param: mixed $data return: string a string containing a byte-stream representation of |
unserialize($str) X-Ref |
Uses igbinary unserializer if igbinary extension is loaded. Fallback to PHP unserializer. param: string $str return: mixed The converted value is returned, and can be a boolean, |
get($key) X-Ref |
Retrieves an item from the cache store given its key. param: string $key The key to retrieve return: mixed The data that was associated with the key, or false if the key did not exist. |
get_many($keys) X-Ref |
Retrieves several items from the cache store in a single transaction. If not all of the items are available in the cache then the data value for those that are missing will be set to false. param: array $keys The array of keys to retrieve return: array An array of items from the cache. There will be an item for each key, those that were not in the store will |
set($key, $data, $testmaxsize = true) X-Ref |
Sets an item in the cache given its key and data value. param: string $key The key to use. param: mixed $data The data to set. param: bool $testmaxsize If set to true then we test the maxsize arg and reduce if required. return: bool True if the operation was a success false otherwise. |
set_many(array $keyvaluearray) X-Ref |
Sets many items in the cache in a single transaction. param: array $keyvaluearray An array of key value pairs. Each item in the array will be an associative array with two return: int The number of items successfully set. It is up to the developer to check this matches the number of items |
has($key) X-Ref |
Checks if the store has a record for the given key and returns true if so. param: string $key return: bool |
has_all(array $keys) X-Ref |
Returns true if the store contains records for all of the given keys. param: array $keys return: bool |
has_any(array $keys) X-Ref |
Returns true if the store contains records for any of the given keys. param: array $keys return: bool |
delete($key) X-Ref |
Deletes an item from the cache store. param: string $key The key to delete. return: bool Returns true if the operation was a success, false otherwise. |
delete_many(array $keys) X-Ref |
Deletes several keys from the cache in a single action. param: array $keys The keys to delete return: int The number of items successfully deleted. |
purge() X-Ref |
Purges the cache deleting all items within it. return: boolean True on success. False otherwise. |
reduce_for_maxsize() X-Ref |
Reduces the size of the array if maxsize has been hit. This function reduces the size of the store reducing it by 10% of its maxsize. It removes the oldest items in the store when doing this. The reason it does this an doesn't use a least recently used system is purely the overhead such a system requires. The current approach is focused on speed, MUC already adds enough overhead to static/session caches and avoiding more is of benefit. return: int |
can_add_instance() X-Ref |
Returns true if the user can add an instance of the store plugin. return: bool |
instance_deleted() X-Ref |
Performs any necessary clean up when the store instance is being deleted. |
initialise_test_instance(cache_definition $definition) X-Ref |
Generates an instance of the cache store that can be used for testing. param: cache_definition $definition return: cachestore_static |
unit_test_configuration() X-Ref |
Generates the appropriate configuration required for unit testing. return: array Array of unit test configuration data to be used by initialise(). |
my_name() X-Ref |
Returns the name of this instance. return: string |
find_all() X-Ref |
Finds all of the keys being stored in the cache store instance. return: array |
find_by_prefix($prefix) X-Ref |
Finds all of the keys whose keys start with the given prefix. param: string $prefix |