mirror of
https://github.com/moodle/moodle.git
synced 2025-06-02 06:05:31 +02:00
MDL-67020 Cache: Release locks in cache_application::get_many()
This commit is contained in:
parent
9e7d9a0e9b
commit
c06fc0648d
13
cache/classes/loaders.php
vendored
13
cache/classes/loaders.php
vendored
@ -1809,10 +1809,11 @@ class cache_application extends cache implements cache_loader_with_locking {
|
||||
* @throws coding_exception
|
||||
*/
|
||||
public function get_many(array $keys, $strictness = IGNORE_MISSING) {
|
||||
$locks = [];
|
||||
if ($this->requirelockingread) {
|
||||
foreach ($keys as $id => $key) {
|
||||
$lock =$this->acquire_lock($key);
|
||||
if (!$lock) {
|
||||
$locks[$key] = $this->acquire_lock($key);
|
||||
if (!$locks[$key]) {
|
||||
if ($strictness === MUST_EXIST) {
|
||||
throw new coding_exception('Could not acquire read locks for all of the items being requested.');
|
||||
} else {
|
||||
@ -1823,7 +1824,13 @@ class cache_application extends cache implements cache_loader_with_locking {
|
||||
|
||||
}
|
||||
}
|
||||
return parent::get_many($keys, $strictness);
|
||||
$result = parent::get_many($keys, $strictness);
|
||||
if ($this->requirelockingread) {
|
||||
foreach ($locks as $key => $lock) {
|
||||
$this->release_lock($key);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user