ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
DefinitionCache.php
Go to the documentation of this file.
1 <?php
2 
12 {
13 
14  public $type;
15 
20  public function __construct($type) {
21  $this->type = $type;
22  }
23 
28  public function generateKey($config) {
29  return $config->version . ',' . // possibly replace with function calls
30  $config->getBatchSerial($this->type) . ',' .
31  $config->get($this->type . '.DefinitionRev');
32  }
33 
40  public function isOld($key, $config) {
41  if (substr_count($key, ',') < 2) return true;
42  list($version, $hash, $revision) = explode(',', $key, 3);
43  $compare = version_compare($version, $config->version);
44  // version mismatch, is always old
45  if ($compare != 0) return true;
46  // versions match, ids match, check revision number
47  if (
48  $hash == $config->getBatchSerial($this->type) &&
49  $revision < $config->get($this->type . '.DefinitionRev')
50  ) return true;
51  return false;
52  }
53 
60  public function checkDefType($def) {
61  if ($def->type !== $this->type) {
62  trigger_error("Cannot use definition of type {$def->type} in cache for {$this->type}");
63  return false;
64  }
65  return true;
66  }
67 
71  abstract public function add($def, $config);
72 
76  abstract public function set($def, $config);
77 
81  abstract public function replace($def, $config);
82 
86  abstract public function get($config);
87 
91  abstract public function remove($config);
92 
96  abstract public function flush($config);
97 
104  abstract public function cleanup($config);
105 
106 }
107 
108 // vim: et sw=4 sts=4