Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
core\local\guzzle\cache_handler Class Reference

Public Member Functions

 __construct (string $module='repository')
 Constructor for class cache_handler.
 
 clear ()
 Deletes all items in the pool.
 
 commit ()
 Persists any deferred cache items.
 
 delete_item (string $key)
 Removes the item from the pool.
 
 delete_items (array $keys)
 Removes multiple items from the pool.
 
 get_item (string$key, ?int $ttl=null)
 Returns a Cache Item representing the specified key.
 
 get_items (array $keys=[])
 Returns a traversable set of cache items.
 
 has_item ($key)
 Confirms if the cache contains specified cache item.
 
 refresh (int $ttl)
 Refreshes all items in the pool.
 
 save (cache_item $item)
 Persists a cache item immediately.
 
 save_deferred (cache_item $item)
 Sets a cache item to be persisted later.
 

Constructor & Destructor Documentation

◆ __construct()

core\local\guzzle\cache_handler::__construct ( string $module = 'repository')

Constructor for class cache_handler.

This class will accept the module which will determine the location of cached files.

Parameters
string$modulemodule string for cache directory.

Member Function Documentation

◆ clear()

core\local\guzzle\cache_handler::clear ( )

Deletes all items in the pool.

Return values
boolTrue if the pool was successfully cleared. False if there was an error.

◆ commit()

core\local\guzzle\cache_handler::commit ( )

Persists any deferred cache items.

Return values
boolTrue if all not-yet-saved items were successfully saved or there were none. False otherwise.

◆ delete_item()

core\local\guzzle\cache_handler::delete_item ( string $key)

Removes the item from the pool.

Parameters
string$keyThe key to delete.
Return values
boolTrue if the item was successfully removed. False if there was an error.

◆ delete_items()

core\local\guzzle\cache_handler::delete_items ( array $keys)

Removes multiple items from the pool.

Parameters
string[]$keysAn array of keys that should be removed from the pool.
Return values
boolTrue if the items were successfully removed. False if there was an error.

◆ get_item()

core\local\guzzle\cache_handler::get_item ( string$key ,
?int $ttl = null )

Returns a Cache Item representing the specified key.

This method must always return a CacheItemInterface object, even in case of a cache miss. It MUST NOT return null.

Parameters
string$keyThe key for which to return the corresponding Cache Item..
int | null$ttlNumber of seconds for the cache item to live.
Return values
cache_itemThe corresponding Cache Item.

◆ get_items()

core\local\guzzle\cache_handler::get_items ( array $keys = [])

Returns a traversable set of cache items.

Parameters
string[]$keysAn indexed array of keys of items to retrieve.
Return values
iterableAn iterable collection of Cache Items keyed by the cache keys of each item. A Cache item will be returned for each key, even if that key is not found. However, if no keys are specified then an empty traversable MUST be returned instead.

◆ has_item()

core\local\guzzle\cache_handler::has_item ( $key)

Confirms if the cache contains specified cache item.

Note: This method MAY avoid retrieving the cached value for performance reasons. This could result in a race condition with CacheItemInterface\get(). To avoid such situation use CacheItemInterface\isHit() instead.

Parameters
string$keyThe key for which to check existence.
Return values
boolTrue if item exists in the cache, false otherwise.

◆ refresh()

core\local\guzzle\cache_handler::refresh ( int $ttl)

Refreshes all items in the pool.

Parameters
int$ttlSeconds to live.
Return values
void

◆ save()

core\local\guzzle\cache_handler::save ( cache_item $item)

Persists a cache item immediately.

Parameters
cache_item$itemThe cache item to save.
Return values
boolTrue if the item was successfully persisted. False if there was an error.

◆ save_deferred()

core\local\guzzle\cache_handler::save_deferred ( cache_item $item)

Sets a cache item to be persisted later.

Parameters
cache_item$itemThe cache item to save.
Return values
boolFalse if the item could not be queued or if a commit was attempted and failed. True otherwise.

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