ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
arObjectCache Class Reference

Class arObjectCache. More...

+ Collaboration diagram for arObjectCache:

Static Public Member Functions

static isCached ($class, $id)
 
static store (ActiveRecord $object)
 
static printStats ()
 
static get ($class, $id)
 
static purge (ActiveRecord $object)
 
static flush ($class_name)
 

Static Protected Attributes

static $cache = array()
 

Detailed Description

Class arObjectCache.

Version
2.0.7
Author
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch

Definition at line 11 of file class.arObjectCache.php.

Member Function Documentation

◆ flush()

static arObjectCache::flush (   $class_name)
static
Parameters
$class_name

Definition at line 111 of file class.arObjectCache.php.

References CachedActiveRecord\getCacheIdentifier().

Referenced by ilOrgUnitPosition\getActive(), and ilOrgUnitPosition\getActiveForPosition().

112  {
113  $instance = new $class_name();
114  if ($instance instanceof CachedActiveRecord && $instance->getCacheIdentifier() != '') {
115  $instance->getCache()->flush();
116  }
117 
118  if ($class_name instanceof ActiveRecord) {
119  $class_name = get_class($class_name);
120  }
121  unset(self::$cache[$class_name]);
122  }
Class CachedActiveRecord.
Class ActiveRecord.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get()

static arObjectCache::get (   $class,
  $id 
)
static
Parameters
$class
$id
Exceptions
arException
Returns
ActiveRecord

Definition at line 80 of file class.arObjectCache.php.

References $id, arException\GET_UNCACHED_OBJECT, and CachedActiveRecord\getCacheIdentifier().

Referenced by ActiveRecord\additionalParams(), and ActiveRecord\buildFromArray().

81  {
82  $instance = new $class();
83  if ($instance instanceof CachedActiveRecord && $instance->getCacheIdentifier() != '') {
84  if ($instance->getCache()->exists($instance->getCacheIdentifier())) {
85  return $instance->getCache()->get($instance->getCacheIdentifier());
86  }
87  }
88  if (!self::isCached($class, $id)) {
89  throw new arException(arException::GET_UNCACHED_OBJECT, $class . ': ' . $id);
90  }
91 
92  return self::$cache[$class][$id];
93  }
Class CachedActiveRecord.
const GET_UNCACHED_OBJECT
if(!array_key_exists('StateId', $_REQUEST)) $id
Class arException.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isCached()

static arObjectCache::isCached (   $class,
  $id 
)
static
Parameters
$class
$id
Returns
bool

Definition at line 26 of file class.arObjectCache.php.

References $id, and CachedActiveRecord\getCacheIdentifier().

Referenced by ActiveRecord\additionalParams(), and ActiveRecord\buildFromArray().

27  {
28  $instance = new $class();
29  if ($instance instanceof CachedActiveRecord && $instance->getCacheIdentifier() != '') {
30  if ($instance->getCache()->exists($instance->getCacheIdentifier())) {
31  return true;
32  }
33  }
34 
35  if (!isset(self::$cache[$class])) {
36  return false;
37  }
38  if (!isset(self::$cache[$class][$id]) || !self::$cache[$class][$id] instanceof ActiveRecord) {
39  return false;
40  }
41 
42  return in_array($id, array_keys(self::$cache[$class]));
43  }
Class CachedActiveRecord.
Class ActiveRecord.
if(!array_key_exists('StateId', $_REQUEST)) $id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ printStats()

static arObjectCache::printStats ( )
static

Definition at line 62 of file class.arObjectCache.php.

63  {
64  foreach (self::$cache as $class => $objects) {
65  echo $class;
66  echo ": ";
67  echo count($objects);
68  echo " Objects<br>";
69  }
70  }

◆ purge()

static arObjectCache::purge ( ActiveRecord  $object)
static
Parameters
ActiveRecord$object

Definition at line 99 of file class.arObjectCache.php.

References ActiveRecord\delete(), and ActiveRecord\getPrimaryFieldValue().

Referenced by ActiveRecord\delete().

100  {
101  if ($object instanceof CachedActiveRecord && $object->getCacheIdentifier() != '') {
102  $object->getCache()->delete($object->getCacheIdentifier());
103  }
104  unset(self::$cache[get_class($object)][$object->getPrimaryFieldValue()]);
105  }
Class CachedActiveRecord.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ store()

static arObjectCache::store ( ActiveRecord  $object)
static
Parameters
ActiveRecord$object

Definition at line 49 of file class.arObjectCache.php.

References ActiveRecord\getPrimaryFieldValue().

Referenced by ActiveRecord\buildFromArray(), ActiveRecord\create(), ActiveRecord\read(), ActiveRecord\storeObjectToCache(), and ActiveRecord\update().

50  {
51  if ($object instanceof CachedActiveRecord && $object->getCacheIdentifier() != '') {
52  if ($object->getCache()->set($object->getCacheIdentifier(), $object, $object->getTTL())) {
53  return;
54  }
55  }
56  if (!isset($object->is_new)) {
57  self::$cache[get_class($object)][$object->getPrimaryFieldValue()] = $object;
58  }
59  }
Class CachedActiveRecord.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $cache

arObjectCache::$cache = array()
staticprotected

Definition at line 17 of file class.arObjectCache.php.


The documentation for this class was generated from the following file: