MDL-82158 core_cache: Move interfaces
This commit is contained in:
+56
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
interface cache_is_lockable {
|
||||
|
||||
/**
|
||||
* Acquires a lock on the given key for the given identifier.
|
||||
*
|
||||
* @param string $key The key we are locking.
|
||||
* @param string $ownerid The 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 bool True if the lock could be acquired, false otherwise.
|
||||
*/
|
||||
public function acquire_lock($key, $ownerid);
|
||||
|
||||
/**
|
||||
* Test if there is already a lock for the given key and if there is whether it belongs to the calling code.
|
||||
*
|
||||
* @param string $key The key we are locking.
|
||||
* @param string $ownerid The identifier so we can check if we have the lock or if it is someone else.
|
||||
* @return bool True 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.
|
||||
*/
|
||||
public function check_lock_state($key, $ownerid);
|
||||
|
||||
/**
|
||||
* Releases the lock on the given key.
|
||||
*
|
||||
* @param string $key The key we are locking.
|
||||
* @param string $ownerid The 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 bool True if the lock has been released, false if there was a problem releasing the lock.
|
||||
*/
|
||||
public function release_lock($key, $ownerid);
|
||||
}
|
||||
Reference in New Issue
Block a user