ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
DefinitionCache.php
Go to the documentation of this file.
1<?php
2
12{
16 public $type;
17
22 public function __construct($type)
23 {
24 $this->type = $type;
25 }
26
32 public function generateKey($config)
33 {
34 return $config->version . ',' . // possibly replace with function calls
35 $config->getBatchSerial($this->type) . ',' .
36 $config->get($this->type . '.DefinitionRev');
37 }
38
46 public function isOld($key, $config)
47 {
48 if (substr_count($key, ',') < 2) {
49 return true;
50 }
51 list($version, $hash, $revision) = explode(',', $key, 3);
52 $compare = version_compare($version, $config->version);
53 // version mismatch, is always old
54 if ($compare != 0) {
55 return true;
56 }
57 // versions match, ids match, check revision number
58 if ($hash == $config->getBatchSerial($this->type) &&
59 $revision < $config->get($this->type . '.DefinitionRev')) {
60 return true;
61 }
62 return false;
63 }
64
71 public function checkDefType($def)
72 {
73 if ($def->type !== $this->type) {
74 trigger_error("Cannot use definition of type {$def->type} in cache for {$this->type}");
75 return false;
76 }
77 return true;
78 }
79
85 abstract public function add($def, $config);
86
92 abstract public function set($def, $config);
93
99 abstract public function replace($def, $config);
100
105 abstract public function get($config);
106
111 abstract public function remove($config);
112
117 abstract public function flush($config);
118
126 abstract public function cleanup($config);
127}
128
129// vim: et sw=4 sts=4
Abstract class representing Definition cache managers that implements useful common methods and is a ...
replace($def, $config)
Replace an object in the cache.
checkDefType($def)
Checks if a definition's type jives with the cache's type.
isOld($key, $config)
Tests whether or not a key is old with respect to the configuration's version and revision number.
flush($config)
Clears all objects from cache.
add($def, $config)
Adds a definition object to the cache.
generateKey($config)
Generates a unique identifier for a particular configuration.
cleanup($config)
Clears all expired (older version or revision) objects from cache.