Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | List of all members
cache_is_lockable Interface Reference

Cache store feature: locking. More...

Inheritance diagram for cache_is_lockable:
cachestore_redis

Public Member Functions

 acquire_lock ($key, $ownerid)
 Acquires a lock on the given key for the given identifier. More...
 
 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. More...
 
 release_lock ($key, $ownerid)
 Releases the lock on the given key. More...
 

Detailed Description

Cache store feature: locking.

This is a feature that cache stores can implement if they wish to support locking themselves rather than having the cache loader handle it for them.

Can be implemented by classes already implementing cache_store.

Member Function Documentation

◆ acquire_lock()

cache_is_lockable::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_redis.

◆ check_lock_state()

cache_is_lockable::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_redis.

◆ release_lock()

cache_is_lockable::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_redis.


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