blob: d2287c32a5f662e5c98af4cf764d334f51e549ec (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
<?php
/**
* Model for a stored cache operation.
*
* This model represents a stored cache operation when the used cache object
* was proxied. This occurs when the configured cache object failed to load
* correctly or when the configured cache cannot be used in the respective
* environment. In CLI mode, some caches may not be used since the
* surrounding web server component is missing.
*
* @author Jan-Hendrik Willms <tleilax+studip@gmail.com>
* @license GPL2 or any later version
* @since Stud.IP 3.3
*
* @property array $id alias for pk
* @property string $cache_key database column
* @property string $operation database column
* @property string $parameters database column
* @property int $mkdate database column
* @property int $chdate database column
*/
class StudipCacheOperation extends SimpleORMap
{
/**
* Configures the model.
*
* @param Array $config The config settings
*/
public static function configure($config = [])
{
$config['db_table'] = 'cache_operations';
parent::configure($config);
}
/**
* Applies any pending cache operation to the passed cache object.
* The operations are applied in chronological order and are deleted
* from the database after they have been applied.
*
* @param StudipCache $cache The cache object to apply the operations to
*/
public static function apply(StudipCache $cache)
{
self::findEachBySQL(function (StudipCacheOperation $item) use ($cache): void {
$parameters = unserialize($item->parameters);
array_unshift($parameters, $item->cache_key);
call_user_func_array([$cache, $item->operation], $parameters);
$item->delete();
}, '1 ORDER BY chdate ASC');
}
}
|