Moodle PHP Documentation 5.1
Moodle 5.1dev (Build: 20250620) (7d9030acd6e)
core_cache\lockable_cache_interface Interface Reference
Inheritance diagram for core_cache\lockable_cache_interface:
cachestore_file cachestore_redis

Public Member Functions

 acquire_lock ($key, $ownerid)
 Acquires a lock on the given key for the given identifier.
 
 check_lock_state ($key, $ownerid)
 Test if there is already a lock for the given key and if there is whether it belongs to the calling code.
 
 release_lock ($key, $ownerid)
 Releases the lock on the given key.
 

Member Function Documentation

◆ acquire_lock()

core_cache\lockable_cache_interface::acquire_lock ( $key,
$ownerid )

Acquires a lock on the given key for the given identifier.

Parameters
string$keyThe key we are locking.
string$owneridThe identifier so we can check if we have the lock or if it is someone else. The use of this property is entirely optional and implementations can act as they like upon it.
Return values
boolTrue if the lock could be acquired, false otherwise.

Implemented in cachestore_file, and cachestore_redis.

◆ check_lock_state()

core_cache\lockable_cache_interface::check_lock_state ( $key,
$ownerid )

Test if there is already a lock for the given key and if there is whether it belongs to the calling code.

Parameters
string$keyThe key we are locking.
string$owneridThe identifier so we can check if we have the lock or if it is someone else.
Return values
boolTrue if this code has the lock, false if there is a lock but this code doesn't have it, null if there is no lock.

Implemented in cachestore_file, and cachestore_redis.

◆ release_lock()

core_cache\lockable_cache_interface::release_lock ( $key,
$ownerid )

Releases the lock on the given key.

Parameters
string$keyThe key we are locking.
string$owneridThe identifier so we can check if we have the lock or if it is someone else. The use of this property is entirely optional and implementations can act as they like upon it.
Return values
boolTrue if the lock has been released, false if there was a problem releasing the lock.

Implemented in cachestore_file, and cachestore_redis.


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