MDL-40555 cache: Static store is searchable

This commit is contained in:
Frederic Massart 2013-07-08 15:09:04 +08:00
parent f8e6e5bc30
commit 0d8eac408b

View File

@ -86,7 +86,7 @@ abstract class static_data_store extends cache_store {
* @copyright 2012 Sam Hemelryk
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class cachestore_static extends static_data_store implements cache_is_key_aware {
class cachestore_static extends static_data_store implements cache_is_key_aware, cache_is_searchable {
/**
* The name of the store
@ -133,7 +133,8 @@ class cachestore_static extends static_data_store implements cache_is_key_aware
*/
public static function get_supported_features(array $configuration = array()) {
return self::SUPPORTS_DATA_GUARANTEE +
self::SUPPORTS_NATIVE_TTL;
self::SUPPORTS_NATIVE_TTL +
self::IS_SEARCHABLE;
}
/**
@ -411,4 +412,28 @@ class cachestore_static extends static_data_store implements cache_is_key_aware
public function my_name() {
return $this->name;
}
}
/**
* Finds all of the keys being stored in the cache store instance.
*
* @return array
*/
public function find_all() {
return array_keys($this->store);
}
/**
* Finds all of the keys whose keys start with the given prefix.
*
* @param string $prefix
*/
public function find_by_prefix($prefix) {
$return = array();
foreach ($this->find_all() as $key) {
if (strpos($key, $prefix) === 0) {
$return[] = $key;
}
}
return $return;
}
}