Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250620) (7d9030acd6e)
Psr\SimpleCache\CacheInterface Interface Reference
Inheritance diagram for Psr\SimpleCache\CacheInterface:
PhpOffice\PhpSpreadsheet\Collection\Memory\SimpleCache1 PhpOffice\PhpSpreadsheet\Collection\Memory\SimpleCache3

Public Member Functions

 clear ()
 Wipes clean the entire cache's keys.
 
 delete (string $key)
 Delete an item from the cache by its unique key.
 
 deleteMultiple (iterable $keys)
 Deletes multiple cache items in a single operation.
 
 get (string $key, mixed $default=null)
 
 getMultiple (iterable $keys, mixed $default=null)
 Obtains multiple cache items by their unique keys.
 
 has (string $key)
 Determines whether an item is present in the cache.
 
 set (string $key, mixed $value, null|int|DateInterval $ttl=null)
 Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time.
 
 setMultiple (iterable $values, null|int|DateInterval $ttl=null)
 Persists a set of key => value pairs in the cache, with an optional TTL.
 

Member Function Documentation

◆ clear()

Psr\SimpleCache\CacheInterface::clear ( )

Wipes clean the entire cache's keys.

Return values
boolTrue on success and false on failure.

Implemented in PhpOffice\PhpSpreadsheet\Collection\Memory\SimpleCache1, and PhpOffice\PhpSpreadsheet\Collection\Memory\SimpleCache3.

◆ delete()

Psr\SimpleCache\CacheInterface::delete ( string $key)

Delete an item from the cache by its unique key.

Parameters
string$keyThe unique cache key of the item to delete.
Return values
boolTrue if the item was successfully removed. False if there was an error.
Exceptions
Psr\SimpleCache\InvalidArgumentExceptionMUST be thrown if the $key string is not a legal value.

Implemented in PhpOffice\PhpSpreadsheet\Collection\Memory\SimpleCache3.

◆ deleteMultiple()

Psr\SimpleCache\CacheInterface::deleteMultiple ( iterable $keys)

Deletes multiple cache items in a single operation.

Parameters
iterable<string>$keys A list of string-based keys to be deleted.
Return values
boolTrue if the items were successfully removed. False if there was an error.
Exceptions
Psr\SimpleCache\InvalidArgumentExceptionMUST be thrown if $keys is neither an array nor a Traversable, or if any of the $keys are not a legal value.

Implemented in PhpOffice\PhpSpreadsheet\Collection\Memory\SimpleCache3.

◆ getMultiple()

Psr\SimpleCache\CacheInterface::getMultiple ( iterable $keys,
mixed $default = null )

Obtains multiple cache items by their unique keys.

Parameters
iterable<string>$keys A list of keys that can be obtained in a single operation.
mixed$defaultDefault value to return for keys that do not exist.
Return values
iterable<string,mixed>A list of key => value pairs. Cache keys that do not exist or are stale will have $default as value.
Exceptions
Psr\SimpleCache\InvalidArgumentExceptionMUST be thrown if $keys is neither an array nor a Traversable, or if any of the $keys are not a legal value.

Implemented in PhpOffice\PhpSpreadsheet\Collection\Memory\SimpleCache3.

◆ has()

Psr\SimpleCache\CacheInterface::has ( string $key)

Determines whether an item is present in the cache.

NOTE: It is recommended that has() is only to be used for cache warming type purposes and not to be used within your live applications operations for get/set, as this method is subject to a race condition where your has() will return true and immediately after, another script can remove it making the state of your app out of date.

Parameters
string$keyThe cache item key.
Return values
bool
Exceptions
Psr\SimpleCache\InvalidArgumentExceptionMUST be thrown if the $key string is not a legal value.

Implemented in PhpOffice\PhpSpreadsheet\Collection\Memory\SimpleCache3.

◆ set()

Psr\SimpleCache\CacheInterface::set ( string $key,
mixed $value,
null|int|DateInterval $ttl = null )

Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time.

Parameters
string$keyThe key of the item to store.
mixed$valueThe value of the item to store, must be serializable.
null | int | DateInterval$ttlOptional. The TTL value of this item. If no value is sent and the driver supports TTL then the library may set a default value for it or let the driver take care of that.
Return values
boolTrue on success and false on failure.
Exceptions
Psr\SimpleCache\InvalidArgumentExceptionMUST be thrown if the $key string is not a legal value.

Implemented in PhpOffice\PhpSpreadsheet\Collection\Memory\SimpleCache3.

◆ setMultiple()

Psr\SimpleCache\CacheInterface::setMultiple ( iterable $values,
null|int|DateInterval $ttl = null )

Persists a set of key => value pairs in the cache, with an optional TTL.

Parameters
iterable$valuesA list of key => value pairs for a multiple-set operation.
null | int | DateInterval$ttlOptional. The TTL value of this item. If no value is sent and the driver supports TTL then the library may set a default value for it or let the driver take care of that.
Return values
boolTrue on success and false on failure.
Exceptions
Psr\SimpleCache\InvalidArgumentExceptionMUST be thrown if $values is neither an array nor a Traversable, or if any of the $values are not a legal value.

Implemented in PhpOffice\PhpSpreadsheet\Collection\Memory\SimpleCache3.


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