MDL-72596 core_cache: Track cache I/O size in perfdebug
For cache types which mean this information can be obtained without a significant performance cost (i.e. just by calling strlen and not having to serialize something that wasn't serialized already), this change calculates the size of data read from or written to cache in each request and includes it in the perfdebug table at bottom of output (when that is turned on). This supports the following cache types: * File store * Redis (only if caching is enabled)
This commit is contained in:
Vendored
+24
@@ -149,6 +149,11 @@ abstract class cache_store implements cache_store_interface {
|
||||
*/
|
||||
const STATIC_ACCEL = '** static accel. **';
|
||||
|
||||
/**
|
||||
* Returned from get_last_io_bytes if this cache store doesn't support counting bytes read/sent.
|
||||
*/
|
||||
const IO_BYTES_NOT_SUPPORTED = -1;
|
||||
|
||||
/**
|
||||
* Constructs an instance of the cache store.
|
||||
*
|
||||
@@ -392,4 +397,23 @@ abstract class cache_store implements cache_store_interface {
|
||||
public static function ready_to_be_used_for_testing() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 int Bytes read (or 0 if none/not supported)
|
||||
* @since Moodle 4.0
|
||||
*/
|
||||
public function get_last_io_bytes(): int {
|
||||
return self::IO_BYTES_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user