ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
ilGlobalCacheService Class Reference

Class ilGlobalCacheService. More...

+ Inheritance diagram for ilGlobalCacheService:
+ Collaboration diagram for ilGlobalCacheService:

Public Member Functions

 __construct ($service_id, $component)
 
 __destruct ()
 
 unserialize ($serialized_value)
 
 get ($key)
 
 set ($key, $serialized_value, $ttl=NULL)
 
 serialize ($value)
 
 getServiceId ()
 
 setServiceId ($service_id)
 
 setValid ($key)
 
 getComponent ()
 
 setComponent ($component)
 
 setInvalid ($key=NULL)
 
 isValid ($key)
 
 isActive ()
 
 isInstallable ()
 
 returnKey ($key)
 
 getInfo ()
 
 getInstallationFailureReason ()
 
 exists ($key)
 
 delete ($key)
 
 flush ()
 
 setServiceType ($service_type)
 
 getServiceType ()
 

Protected Member Functions

 saveValid ()
 
 readValid ()
 
 getActive ()
 
 getInstallable ()
 
 getMemoryLimit ()
 
 getMinMemory ()
 
 checkMemory ()
 

Protected Attributes

 $current_time = 0
 
 $valid_keys = array()
 
 $service_id = ''
 
 $component = ''
 
 $service_type = ilGlobalCache::TYPE_STATIC
 
 $valid_key_hash = ''
 

Static Protected Attributes

static $active = array()
 
static $installable = array()
 

Detailed Description

Class ilGlobalCacheService.

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

Definition at line 9 of file class.ilGlobalCacheService.php.

Constructor & Destructor Documentation

◆ __construct()

ilGlobalCacheService::__construct (   $service_id,
  $component 
)
Parameters
$service_id
$component

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

References $component, $service_id, checkMemory(), getActive(), getInstallable(), readValid(), setComponent(), and setServiceId().

49  {
50  $this->setComponent($component);
51  $this->setServiceId($service_id);
52  self::$active[get_called_class()] = $this->getActive();
53  self::$installable[get_called_class()] = ($this->getInstallable() AND $this->checkMemory());
54  // $this->current_time = time();
55  $this->readValid();
56  }
+ Here is the call graph for this function:

◆ __destruct()

ilGlobalCacheService::__destruct ( )

Definition at line 59 of file class.ilGlobalCacheService.php.

References saveValid().

59  {
60  $this->saveValid();
61  }
+ Here is the call graph for this function:

Member Function Documentation

◆ checkMemory()

ilGlobalCacheService::checkMemory ( )
protected
Returns
bool

Definition at line 272 of file class.ilGlobalCacheService.php.

References exists(), flush(), getMemoryLimit(), and getMinMemory().

Referenced by __construct(), and getInstallationFailureReason().

272  {
273  $matches = array();
274  $memory_limit = $this->getMemoryLimit();
275  if (preg_match('/([0-9]*)([M|K])/uism', $memory_limit, $matches)) {
276  switch ($matches[2]) {
277  case 'M':
278  $memory_limit = $matches[1] * 1024 * 1024; // nnnM -> nnn MB
279  break;
280  case 'K':
281  $memory_limit = $matches[1] * 1024; // nnnK -> nnn KB
282  break;
283  }
284  } else {
285  $memory_limit = $memory_limit * 1024 * 1024; // nnnM -> nnn MB
286  }
287 
288  return ($memory_limit >= $this->getMinMemory() * 1024 * 1024);
289  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilGlobalCacheService::delete (   $key)
abstract
Parameters
$key
Returns
bool

◆ exists()

ilGlobalCacheService::exists (   $key)
abstract
Parameters
$key
Returns
bool

Referenced by checkMemory().

+ Here is the caller graph for this function:

◆ flush()

ilGlobalCacheService::flush ( )
abstract
Returns
mixed

Referenced by checkMemory().

+ Here is the caller graph for this function:

◆ get()

ilGlobalCacheService::get (   $key)
abstract
Parameters
$key
Returns
mixed

◆ getActive()

ilGlobalCacheService::getActive ( )
abstractprotected
Returns
bool

Referenced by __construct(), and readValid().

+ Here is the caller graph for this function:

◆ getComponent()

ilGlobalCacheService::getComponent ( )
Returns
string

Definition at line 167 of file class.ilGlobalCacheService.php.

References $component.

Referenced by ilStaticCache\delete(), ilStaticCache\exists(), ilStaticCache\get(), ilApc\getInfo(), returnKey(), and ilStaticCache\set().

167  {
168  return $this->component;
169  }
+ Here is the caller graph for this function:

◆ getInfo()

ilGlobalCacheService::getInfo ( )
Returns
array

Definition at line 233 of file class.ilGlobalCacheService.php.

233  {
234  return array();
235  }

◆ getInstallable()

ilGlobalCacheService::getInstallable ( )
abstractprotected
Returns
bool

Referenced by __construct(), getInstallationFailureReason(), and readValid().

+ Here is the caller graph for this function:

◆ getInstallationFailureReason()

ilGlobalCacheService::getInstallationFailureReason ( )
Returns
string

Definition at line 241 of file class.ilGlobalCacheService.php.

References checkMemory(), getInstallable(), and getMinMemory().

241  {
242  if (! $this->getInstallable()) {
243  return 'Not installed';
244  }
245  if (! $this->checkMemory()) {
246  return 'Not enough Cache-Memory, set to at least ' . $this->getMinMemory() . 'M';
247  }
248 
249  return 'Unknown reason';
250  }
+ Here is the call graph for this function:

◆ getMemoryLimit()

ilGlobalCacheService::getMemoryLimit ( )
protected
Returns
int

Definition at line 256 of file class.ilGlobalCacheService.php.

Referenced by checkMemory().

256  {
257  return 9999;
258  }
+ Here is the caller graph for this function:

◆ getMinMemory()

ilGlobalCacheService::getMinMemory ( )
protected
Returns
int

Definition at line 264 of file class.ilGlobalCacheService.php.

Referenced by checkMemory(), and getInstallationFailureReason().

264  {
265  return 0;
266  }
+ Here is the caller graph for this function:

◆ getServiceId()

ilGlobalCacheService::getServiceId ( )
Returns
string

Definition at line 140 of file class.ilGlobalCacheService.php.

References $service_id.

Referenced by ilApc\getInfo(), and returnKey().

140  {
141  return $this->service_id;
142  }
+ Here is the caller graph for this function:

◆ getServiceType()

ilGlobalCacheService::getServiceType ( )
Returns
int

Definition at line 325 of file class.ilGlobalCacheService.php.

References $service_type.

◆ isActive()

ilGlobalCacheService::isActive ( )
Returns
bool

Definition at line 205 of file class.ilGlobalCacheService.php.

Referenced by ilXcache\getInfo(), readValid(), and saveValid().

205  {
206  return self::$active[get_called_class()];
207  }
+ Here is the caller graph for this function:

◆ isInstallable()

ilGlobalCacheService::isInstallable ( )
Returns
bool

Definition at line 213 of file class.ilGlobalCacheService.php.

213  {
214  return self::$installable[get_called_class()];
215  }

◆ isValid()

ilGlobalCacheService::isValid (   $key)
Parameters
$key
Returns
bool

Definition at line 197 of file class.ilGlobalCacheService.php.

197  {
198  return isset($this->valid_keys[$key]);
199  }

◆ readValid()

ilGlobalCacheService::readValid ( )
protected
Returns
bool

set self::$valid_keys from GlobalCache

Definition at line 83 of file class.ilGlobalCacheService.php.

References getActive(), getInstallable(), isActive(), serialize(), and unserialize().

Referenced by __construct().

83  {
84  if ($this->isActive()) {
85  $this->valid_keys = $this->unserialize($this->get('valid_keys'));
86  $this->valid_key_hash = md5(serialize($this->valid_keys));
87  }
88  }
unserialize($serialized_value)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ returnKey()

ilGlobalCacheService::returnKey (   $key)
Parameters
$key
Returns
string

Definition at line 223 of file class.ilGlobalCacheService.php.

References getComponent(), and getServiceId().

Referenced by ilXcache\delete(), ilApc\delete(), ilMemcache\delete(), ilXcache\exists(), ilApc\exists(), ilMemcache\exists(), ilXcache\get(), ilApc\get(), ilMemcache\get(), ilXcache\set(), ilApc\set(), and ilMemcache\set().

223  {
224  return $str = $this->getServiceId() . '_' . $this->getComponent() . '_' . $key;
225 
226  return str_replace('/', '_', $str);
227  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveValid()

ilGlobalCacheService::saveValid ( )
protected
Returns
bool

save self::$valid_keys to GlobalCache

Definition at line 69 of file class.ilGlobalCacheService.php.

References isActive(), and serialize().

Referenced by __destruct().

69  {
70  if ($this->isActive()) {
71  if ($this->valid_key_hash != md5(serialize($this->valid_keys))) {
72  $this->set('valid_keys', $this->serialize($this->valid_keys));
73  }
74  }
75  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serialize()

ilGlobalCacheService::serialize (   $value)
abstract
Parameters
$value
Returns
mixed

Referenced by readValid(), and saveValid().

+ Here is the caller graph for this function:

◆ set()

ilGlobalCacheService::set (   $key,
  $serialized_value,
  $ttl = NULL 
)
abstract
Parameters
$key
$serialized_value
null$ttl
Returns
bool

◆ setComponent()

ilGlobalCacheService::setComponent (   $component)
Parameters
string$component

Definition at line 175 of file class.ilGlobalCacheService.php.

References $component.

Referenced by __construct().

175  {
176  $this->component = $component;
177  }
+ Here is the caller graph for this function:

◆ setInvalid()

ilGlobalCacheService::setInvalid (   $key = NULL)
Parameters
null$key

Definition at line 183 of file class.ilGlobalCacheService.php.

183  {
184  if ($key) {
185  unset($this->valid_keys[$key]);
186  } else {
187  unset($this->valid_keys);
188  }
189  }

◆ setServiceId()

ilGlobalCacheService::setServiceId (   $service_id)
Parameters
string$service_id

Definition at line 148 of file class.ilGlobalCacheService.php.

References $service_id.

Referenced by __construct().

148  {
149  $this->service_id = $service_id;
150  }
+ Here is the caller graph for this function:

◆ setServiceType()

ilGlobalCacheService::setServiceType (   $service_type)
Parameters
int$service_type

Definition at line 317 of file class.ilGlobalCacheService.php.

References $service_type.

317  {
318  $this->service_type = $service_type;
319  }

◆ setValid()

ilGlobalCacheService::setValid (   $key)
Parameters
$key
Returns
bool|void

Definition at line 158 of file class.ilGlobalCacheService.php.

158  {
159  $this->valid_keys[$key] = true;
160  // $this->valid_keys[$key] = time();
161  }

◆ unserialize()

ilGlobalCacheService::unserialize (   $serialized_value)
abstract
Parameters
$serialized_value
Returns
mixed

Referenced by readValid().

+ Here is the caller graph for this function:

Field Documentation

◆ $active

ilGlobalCacheService::$active = array()
staticprotected

Definition at line 22 of file class.ilGlobalCacheService.php.

Referenced by ilXcache\getActive().

◆ $component

ilGlobalCacheService::$component = ''
protected

◆ $current_time

ilGlobalCacheService::$current_time = 0
protected

Definition at line 14 of file class.ilGlobalCacheService.php.

◆ $installable

ilGlobalCacheService::$installable = array()
staticprotected

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

◆ $service_id

ilGlobalCacheService::$service_id = ''
protected

◆ $service_type

ilGlobalCacheService::$service_type = ilGlobalCache::TYPE_STATIC
protected

Definition at line 38 of file class.ilGlobalCacheService.php.

Referenced by getServiceType(), and setServiceType().

◆ $valid_key_hash

ilGlobalCacheService::$valid_key_hash = ''
protected

Definition at line 42 of file class.ilGlobalCacheService.php.

◆ $valid_keys

ilGlobalCacheService::$valid_keys = array()
protected

Definition at line 18 of file class.ilGlobalCacheService.php.


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