ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.arObjectCache.php
Go to the documentation of this file.
1 <?php
2 require_once(dirname(__FILE__) . '/../Exception/class.arException.php');
3 
12 {
13 
17  protected static $cache = array();
18 
19 
26  public static function isCached($class, $id)
27  {
28  if (!isset(self::$cache[$class])) {
29  return false;
30  }
31  if (!isset(self::$cache[$class][$id]) || !self::$cache[$class][$id] instanceof ActiveRecord) {
32  return false;
33  }
34 
35  return in_array($id, array_keys(self::$cache[$class]));
36  }
37 
38 
42  public static function store(ActiveRecord $object)
43  {
44  if (!isset($object->is_new)) {
45  self::$cache[get_class($object)][$object->getPrimaryFieldValue()] = $object;
46  }
47  }
48 
49 
50  public static function printStats()
51  {
52  foreach (self::$cache as $class => $objects) {
53  echo $class;
54  echo ": ";
55  echo count($objects);
56  echo " Objects<br>";
57  }
58  }
59 
60 
68  public static function get($class, $id)
69  {
70  if (!self::isCached($class, $id)) {
71  throw new arException(arException::GET_UNCACHED_OBJECT, $class . ': ' . $id);
72  }
73 
74  return self::$cache[$class][$id];
75  }
76 
77 
81  public static function purge(ActiveRecord $object)
82  {
83  unset(self::$cache[get_class($object)][$object->getPrimaryFieldValue()]);
84  }
85 
86 
90  public static function flush($class_name)
91  {
92  if ($class_name instanceof ActiveRecord) {
93  $class_name = get_class($class_name);
94  }
95  unset(self::$cache[$class_name]);
96  }
97 }
Class arObjectCache.
Class ActiveRecord.
const GET_UNCACHED_OBJECT
if(!array_key_exists('StateId', $_REQUEST)) $id
static purge(ActiveRecord $object)
static store(ActiveRecord $object)
Create styles array
The data for the language used.
static flush($class_name)
static isCached($class, $id)
Class arException.