ILIAS  release_8 Revision v8.24
ilGlobalCacheService Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

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

Public Member Functions

 __construct (string $service_id, string $component)
 ilGlobalCacheService constructor. More...
 
 unserialize ($serialized_value)
 
 get (string $key)
 
 set (string $key, $serialized_value, int $ttl=null)
 
 serialize ($value)
 
 getServiceId ()
 
 setServiceId (string $service_id)
 
 getComponent ()
 
 setComponent (string $component)
 
 isActive ()
 
 isInstallable ()
 
 returnKey (string $key)
 
 getInfo ()
 
 getInstallationFailureReason ()
 
 exists (string $key)
 
 delete (string $key)
 
 flush (bool $complete=false)
 
 setServiceType (int $service_type)
 
 getServiceType ()
 
 setValid (string $key)
 Declare a key as valid. More...
 
 isValid (string $key)
 Checks whether the cache key is valid or not. More...
 
 unserialize ($serialized_value)
 
 get (string $key)
 
 set (string $key, $serialized_value, int $ttl=null)
 
 getServiceId ()
 
 setServiceId (string $service_id)
 
 getComponent ()
 
 setComponent (string $component)
 
 isActive ()
 
 isInstallable ()
 
 returnKey (string $key)
 
 getInfo ()
 
 getInstallationFailureReason ()
 
 exists (string $key)
 
 delete (string $key)
 
 flush (bool $complete=false)
 
 setServiceType (int $service_type)
 
 getServiceType ()
 
 setValid (string $key)
 Declare a key as valid. More...
 
 isValid (string $key)
 Checks whether the cache key is valid or not. More...
 

Protected Member Functions

 getActive ()
 
 getInstallable ()
 
 getMemoryLimit ()
 
 getMinMemory ()
 
 checkMemory ()
 

Protected Attributes

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

Static Protected Attributes

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

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilGlobalCacheService Base class for all concrete cache implementations.

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

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

Constructor & Destructor Documentation

◆ __construct()

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

ilGlobalCacheService constructor.

Reimplemented in ilShm.

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

40 {
43 self::$active[static::class] = $this->getActive();
44 self::$installable[static::class] = ($this->getInstallable() && $this->checkMemory());
45 }
setServiceId(string $service_id)

References checkMemory(), getActive(), getInstallable(), setComponent(), and setServiceId().

+ Here is the call graph for this function:

Member Function Documentation

◆ checkMemory()

ilGlobalCacheService::checkMemory ( )
protected

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

135 : bool
136 {
137 $matches = [];
138 $memory_limit = $this->getMemoryLimit();
139 if (preg_match('#(\d*)([M|K])#uim', $memory_limit, $matches)) {
140 if ($matches[2] === 'M') {
141 $memory_limit = $matches[1] * 1024 * 1024;
142 } elseif ($matches[2] === 'K') {
143 $memory_limit = $matches[1] * 1024;
144 }
145 } else {
146 $memory_limit *= 1024 * 1024; // nnnM -> nnn MB
147 }
148
149 return ($memory_limit >= $this->getMinMemory() * 1024 * 1024);
150 }

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 ( string  $key)
abstract

Implements ilGlobalCacheServiceInterface.

Reimplemented in ilApc, ilMemcache, ilShm, and ilStaticCache.

◆ exists()

ilGlobalCacheService::exists ( string  $key)
abstract

Implements ilGlobalCacheServiceInterface.

Reimplemented in ilApc, ilMemcache, ilShm, and ilStaticCache.

◆ flush()

ilGlobalCacheService::flush ( bool  $complete = false)
abstract

Implements ilGlobalCacheServiceInterface.

Reimplemented in ilApc, ilMemcache, ilShm, and ilStaticCache.

◆ get()

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

Implements ilGlobalCacheServiceInterface.

Reimplemented in ilApc, ilMemcache, ilShm, and ilStaticCache.

◆ getActive()

ilGlobalCacheService::getActive ( )
abstractprotected

Reimplemented in ilApc, ilMemcache, ilShm, and ilStaticCache.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ getComponent()

ilGlobalCacheService::getComponent ( )

Implements ilGlobalCacheServiceInterface.

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

83 : string
84 {
85 return $this->component;
86 }

References $component.

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

+ Here is the caller graph for this function:

◆ getInfo()

ilGlobalCacheService::getInfo ( )

Implements ilGlobalCacheServiceInterface.

Reimplemented in ilApc, and ilMemcache.

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

108 : array
109 {
110 return array();
111 }

◆ getInstallable()

ilGlobalCacheService::getInstallable ( )
abstractprotected

Reimplemented in ilApc, ilMemcache, ilShm, and ilStaticCache.

Referenced by __construct(), and getInstallationFailureReason().

+ Here is the caller graph for this function:

◆ getInstallationFailureReason()

ilGlobalCacheService::getInstallationFailureReason ( )

Implements ilGlobalCacheServiceInterface.

Reimplemented in ilMemcache.

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

113 : string
114 {
115 if (!$this->getInstallable()) {
116 return 'Not installed';
117 }
118 if (!$this->checkMemory()) {
119 return 'Not enough Cache-Memory, set to at least ' . $this->getMinMemory() . 'M';
120 }
121
122 return 'Unknown reason';
123 }

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

+ Here is the call graph for this function:

◆ getMemoryLimit()

ilGlobalCacheService::getMemoryLimit ( )
protected

Reimplemented in ilApc.

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

125 : string
126 {
127 return '9999M';
128 }

Referenced by checkMemory().

+ Here is the caller graph for this function:

◆ getMinMemory()

ilGlobalCacheService::getMinMemory ( )
protected

Reimplemented in ilApc.

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

130 : int
131 {
132 return 0;
133 }

Referenced by checkMemory(), and getInstallationFailureReason().

+ Here is the caller graph for this function:

◆ getServiceId()

ilGlobalCacheService::getServiceId ( )

Implements ilGlobalCacheServiceInterface.

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

73 : string
74 {
75 return $this->service_id;
76 }

References $service_id.

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

+ Here is the caller graph for this function:

◆ getServiceType()

ilGlobalCacheService::getServiceType ( )

Implements ilGlobalCacheServiceInterface.

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

163 : int
164 {
165 return $this->service_type;
166 }

References $service_type.

◆ isActive()

ilGlobalCacheService::isActive ( )

Implements ilGlobalCacheServiceInterface.

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

93 : bool
94 {
95 return self::$active[static::class];
96 }

◆ isInstallable()

ilGlobalCacheService::isInstallable ( )

Implements ilGlobalCacheServiceInterface.

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

98 : bool
99 {
100 return self::$installable[static::class];
101 }

Referenced by ilMemcache\getInfo().

+ Here is the caller graph for this function:

◆ isValid()

ilGlobalCacheService::isValid ( string  $key)

Checks whether the cache key is valid or not.

Implements ilGlobalCacheServiceInterface.

Reimplemented in ilApc, and ilMemcache.

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

173 : bool
174 {
175 return isset($this->valid_keys[$key]);
176 }
string $key
Consumer key/client ID value.
Definition: System.php:193

References ILIAS\LTI\ToolProvider\$key.

◆ returnKey()

ilGlobalCacheService::returnKey ( string  $key)

Implements ilGlobalCacheServiceInterface.

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

103 : string
104 {
105 return $this->getServiceId() . '_' . $this->getComponent() . '_' . $key;
106 }

References ILIAS\LTI\ToolProvider\$key, getComponent(), and getServiceId().

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

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

◆ serialize()

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

Reimplemented in ilApc, ilMemcache, ilShm, and ilStaticCache.

◆ set()

ilGlobalCacheService::set ( string  $key,
  $serialized_value,
int  $ttl = null 
)
abstract
Parameters
mixed$serialized_value

Implements ilGlobalCacheServiceInterface.

Reimplemented in ilApc, ilMemcache, ilShm, and ilStaticCache.

◆ setComponent()

ilGlobalCacheService::setComponent ( string  $component)

Implements ilGlobalCacheServiceInterface.

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

88 : void
89 {
90 $this->component = $component;
91 }

References $component.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setServiceId()

ilGlobalCacheService::setServiceId ( string  $service_id)

Implements ilGlobalCacheServiceInterface.

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

78 : void
79 {
80 $this->service_id = $service_id;
81 }

References $service_id.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setServiceType()

ilGlobalCacheService::setServiceType ( int  $service_type)

Implements ilGlobalCacheServiceInterface.

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

158 : void
159 {
160 $this->service_type = $service_type;
161 }

References $service_type.

◆ setValid()

ilGlobalCacheService::setValid ( string  $key)

Declare a key as valid.

If the key is already known no action is taken.

Implements ilGlobalCacheServiceInterface.

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

168 : void
169 {
170 $this->valid_keys[$key] = true;
171 }

References ILIAS\LTI\ToolProvider\$key.

◆ unserialize()

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

Implements ilGlobalCacheServiceInterface.

Reimplemented in ilApc, ilMemcache, ilShm, and ilStaticCache.

Field Documentation

◆ $active

array ilGlobalCacheService::$active = array()
staticprotected

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

◆ $component

string ilGlobalCacheService::$component = ''
protected

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

Referenced by ilShm\__construct(), getComponent(), and setComponent().

◆ $current_time

int ilGlobalCacheService::$current_time = 0
protected

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

◆ $installable

array ilGlobalCacheService::$installable = array()
staticprotected

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

◆ $service_id

string ilGlobalCacheService::$service_id = ''
protected

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

Referenced by ilShm\__construct(), getServiceId(), and setServiceId().

◆ $service_type

int ilGlobalCacheService::$service_type = ilGlobalCache::TYPE_STATIC
protected

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

Referenced by getServiceType(), and setServiceType().

◆ $valid_key_hash

string ilGlobalCacheService::$valid_key_hash = ''
protected

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

◆ $valid_keys

array ilGlobalCacheService::$valid_keys = array()
protected

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


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