|
| __construct ($name='Dummy store', array $configuration=array()) |
| Constructs a dummy store instance.
|
|
| cache_size_details (int $samplekeys=50) |
| Gets the amount of memory used by this specific cache within the store, if known.
|
|
| cleanup () |
| Performs any necessary clean up when the store instance is being deleted.
|
|
| create_clone (array $details=array()) |
| Creates a clone of this store instance ready to be initialised.
|
|
| delete ($key) |
| Deletes an item from the cache.
|
|
| delete_many (array $keys) |
| Deletes many items from the cache.
|
|
| estimate_stored_size ($key, $value) |
| Estimates the storage size used within this cache if the given value is stored with the given key.
|
|
| get ($key) |
| Returns the data for the given key.
|
|
| get_last_io_bytes () |
| Gets the number of bytes read from or written to cache as a result of the last action.
|
|
| get_many ($keys) |
| Gets' the values for many keys.
|
|
| get_warnings () |
| Can be overridden to return any warnings this store instance should make to the admin.
|
|
| initialise (cache_definition $definition) |
| Initialises the store instance for a definition.
|
|
| instance_created () |
| Performs any necessary operation when the store instance has been created.
|
|
| instance_deleted () |
| Performs any necessary operation when the store instance is being deleted.
|
|
| is_initialised () |
| Returns true if this has been initialised.
|
|
| is_ready () |
| Returns true if this cache store instance is ready to use.
|
|
| is_searchable () |
| Returns true if the store instance is searchable.
|
|
| my_name () |
| Returns the name of this instance.
|
|
| purge () |
| Deletes all of the items from the cache.
|
|
| set ($key, $data) |
| Sets an item in the cache.
|
|
| set_many (array $keyvaluearray) |
| Sets many items in the cache.
|
|
| store_total_size () |
| Gets the amount of memory/storage currently used by this cache store if known.
|
|
| supports_data_guarantee () |
| Returns true if the store instance guarantees data.
|
|
| supports_dereferencing_objects () |
| Returns true if the store automatically dereferences objects.
|
|
| supports_multiple_identifiers () |
| Returns true if the store instance supports multiple identifiers.
|
|
| supports_native_ttl () |
| Returns true if the store instance supports native ttl.
|
|
|
const | DEREFERENCES_OBJECTS = 16 |
| The cache store dereferences objects.
|
|
const | IO_BYTES_NOT_SUPPORTED = -1 |
| Returned from get_last_io_bytes if this cache store doesn't support counting bytes read/sent.
|
|
const | IS_SEARCHABLE = 8 |
| The cache is searchable by key.
|
|
const | MODE_APPLICATION = 1 |
| Application caches.
|
|
const | MODE_REQUEST = 4 |
| Request caches.
|
|
const | MODE_SESSION = 2 |
| Session caches.
|
|
const | STATIC_ACCEL = '** static accel. **' |
| Static caches.
|
|
const | SUPPORTS_DATA_GUARANTEE = 2 |
| Ensures data remains in the cache once set.
|
|
const | SUPPORTS_MULTIPLE_IDENTIFIERS = 1 |
| Supports multi-part keys.
|
|
const | SUPPORTS_NATIVE_TTL = 4 |
| Supports a native ttl system.
|
|
cache_store::cache_size_details |
( |
int | $samplekeys = 50 | ) |
|
|
inherited |
Gets the amount of memory used by this specific cache within the store, if known.
This function may be slow and should not be called in normal usage, only for administration pages. The value is usually an estimate, and may not be available at all.
When estimating, a number of sample items will be used for the estimate. If set to 50 (default), then this function will retrieve 50 random items and use that to estimate the total size.
The return value has the following fields:
- supported (true if any other values are completed)
- items (number of items)
- mean (mean size of one item in bytes)
- sd (standard deviation of item size in bytes, based on sample)
- margin (95% confidence margin for mean - will be 0 if exactly computed)
- Parameters
-
int | $samplekeys | Number of samples to use |
- Return values
-
stdClass | Object with information about the store size |
Reimplemented in cachestore_file.
cache_store::estimate_stored_size |
( |
| $key, |
|
|
| $value ) |
|
inherited |
Estimates the storage size used within this cache if the given value is stored with the given key.
This function is not exactly accurate; it does not necessarily take into account all the overheads involved. It is only intended to give a good idea of the relative size of different caches.
The default implementation serializes both key and value and sums the lengths (as a rough estimate which is probably good enough for everything unless the cache offers compression).
- Parameters
-
mixed | $key | Key |
mixed | $value | Value |
- Return values
-
Reimplemented in cachestore_redis.
cache_store::get_last_io_bytes |
( |
| ) |
|
|
inherited |
Gets the number of bytes read from or written to cache as a result of the last action.
This includes calls to the functions get(), get_many(), set(), and set_many(). The number is reset by calling any of these functions.
This should be the actual number of bytes of the value read from or written to cache, giving an impression of the network or other load. It will not be exactly the same amount as netowrk traffic because of protocol overhead, key text, etc.
If not supported, returns IO_BYTES_NOT_SUPPORTED.
- Return values
-
int | Bytes read (or 0 if none/not supported) |
- Since
- Moodle 4.0
Reimplemented in cachestore_file, and cachestore_redis.
static cache_store::ready_to_be_used_for_testing |
( |
| ) |
|
|
staticinherited |
Returns true if this cache store instance is both suitable for testing, and ready for testing.
Cache stores that support being used as the default store for unit and acceptance testing should override this function and return true if there requirements have been met.
- Return values
-
Reimplemented in cachestore_apcu, cachestore_memcached, cachestore_mongodb, and cachestore_redis.
cache_store::store_total_size |
( |
| ) |
|
|
inherited |
Gets the amount of memory/storage currently used by this cache store if known.
This value should be obtained quickly from the store itself, if available.
This is the total memory usage of the entire store, not for ther specific cache in question.
Where not supported (default), will always return null.
- Return values
-
int|null | Amount of memory used in bytes or null |
Reimplemented in cachestore_file, and cachestore_redis.