ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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

Reimplemented in ilShm.

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

49 {
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 }

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

+ Here is the call graph for this function:

◆ __destruct()

ilGlobalCacheService::__destruct ( )

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

59 {
60 $this->saveValid();
61 }

References saveValid().

+ 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.

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 }

References getMemoryLimit(), and getMinMemory().

Referenced by __construct(), and getInstallationFailureReason().

+ 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

Reimplemented in ilApc, ilMemcache, ilShm, ilStaticCache, and ilXcache.

◆ exists()

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

Reimplemented in ilApc, ilMemcache, ilShm, ilStaticCache, and ilXcache.

◆ flush()

ilGlobalCacheService::flush ( )
abstract
Returns
mixed

Reimplemented in ilApc, ilMemcache, ilShm, ilStaticCache, and ilXcache.

◆ get()

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

Reimplemented in ilApc, ilMemcache, ilShm, ilStaticCache, and ilXcache.

◆ getActive()

ilGlobalCacheService::getActive ( )
abstractprotected
Returns
bool

Reimplemented in ilApc, ilMemcache, ilShm, ilStaticCache, and ilXcache.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ getComponent()

ilGlobalCacheService::getComponent ( )
Returns
string

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

167 {
168 return $this->component;
169 }

References $component.

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

+ Here is the caller graph for this function:

◆ getInfo()

ilGlobalCacheService::getInfo ( )
Returns
array

Reimplemented in ilApc, ilMemcache, and ilXcache.

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

233 {
234 return array();
235 }

◆ getInstallable()

ilGlobalCacheService::getInstallable ( )
abstractprotected
Returns
bool

Reimplemented in ilApc, ilMemcache, ilShm, ilStaticCache, and ilXcache.

Referenced by __construct(), and getInstallationFailureReason().

+ Here is the caller graph for this function:

◆ getInstallationFailureReason()

ilGlobalCacheService::getInstallationFailureReason ( )
Returns
string

Reimplemented in ilMemcache.

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

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 }

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

+ Here is the call graph for this function:

◆ getMemoryLimit()

ilGlobalCacheService::getMemoryLimit ( )
protected
Returns
int

Reimplemented in ilApc, and ilXcache.

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

256 {
257 return 9999;
258 }

Referenced by checkMemory().

+ Here is the caller graph for this function:

◆ getMinMemory()

ilGlobalCacheService::getMinMemory ( )
protected
Returns
int

Reimplemented in ilApc, and ilXcache.

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

264 {
265 return 0;
266 }

Referenced by checkMemory(), and getInstallationFailureReason().

+ Here is the caller graph for this function:

◆ getServiceId()

ilGlobalCacheService::getServiceId ( )
Returns
string

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

140 {
141 return $this->service_id;
142 }

References $service_id.

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

+ 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.

205 {
206 return self::$active[get_called_class()];
207 }

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

+ 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

@description set self::$valid_keys from GlobalCache

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

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)

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

Referenced by __construct().

+ 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.

223 {
224 return $str = $this->getServiceId() . '_' . $this->getComponent() . '_' . $key;
225
226 return str_replace('/', '_', $str);
227 }

References getComponent(), and getServiceId().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveValid()

ilGlobalCacheService::saveValid ( )
protected
Returns
bool

@description save self::$valid_keys to GlobalCache

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

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 }

References isActive(), and serialize().

Referenced by __destruct().

+ 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

Reimplemented in ilApc, ilMemcache, ilShm, ilStaticCache, and ilXcache.

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

Reimplemented in ilApc, ilMemcache, ilShm, ilStaticCache, and ilXcache.

◆ setComponent()

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

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

175 {
176 $this->component = $component;
177 }

References $component.

Referenced by __construct().

+ 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.

148 {
149 $this->service_id = $service_id;
150 }

References $service_id.

Referenced by __construct().

+ 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.

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

References $service_type.

◆ 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

Reimplemented in ilApc, ilMemcache, ilShm, ilStaticCache, and ilXcache.

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: