ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 ...
flush($config)
Clears all objects from cache.
$config
Definition: bootstrap.php:15
checkDefType($def)
Checks if a definition&#39;s type jives with the cache&#39;s type.
$version
Definition: build.php:27
cleanup($config)
Clears all expired (older version or revision) objects from cache.
replace($def, $config)
Replace an object in the cache.
add($def, $config)
Adds a definition object to the cache.
isOld($key, $config)
Tests whether or not a key is old with respect to the configuration&#39;s version and revision number...
$def
Definition: croninfo.php:21
generateKey($config)
Generates a unique identifier for a particular configuration.
$key
Definition: croninfo.php:18