ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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