2require_once(
'./Services/GlobalCache/classes/Memcache/class.ilMemcache.php');
3require_once(
'./Services/GlobalCache/classes/Xcache/class.ilXcache.php');
4require_once(
'./Services/GlobalCache/classes/Apc/class.ilApc.php');
5require_once(
'./Services/GlobalCache/classes/Static/class.ilStaticCache.php');
6require_once(
'Settings/class.ilGlobalCacheSettings.php');
16 const MSG =
'Global Cache not active, can not access cache';
64 self::COMP_TPL_BLOCKS,
65 self::COMP_TPL_VARIABLES,
121 $ilGlobalCache->initCachingService();
123 self::$instances[
$component] = $ilGlobalCache;
140 protected function initCachingService() {
148 $ilGlobalCacheService =
new $serviceName(self::$unique_service_id, $this->
getComponent());
150 $this->global_cache = $ilGlobalCacheService;
167 public static function log($message, $log_level) {
168 if ($log_level <= self::getSettings()->getLogLevel()) {
171 $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
172 $function = $backtrace[1][
'function'];
173 $class = $backtrace[1][
'class'];
175 $ilLog->alert($class .
'::' . $function .
'(): ' . $message);
185 if (!isset(self::$unique_service_id)) {
186 self::$unique_service_id = substr(md5(
'il_' . CLIENT_ID), 0, 6);
191 public static function flushAll() {
196 foreach (self::$types as $type) {
198 $service =
new $serviceName(self::generateServiceId(),
'flush');
199 if ($service->isActive()) {
201 $returned = $service->flush();
213 foreach (self::getAllTypes() as $type) {
214 if ($type->isCacheServiceInstallable()) {
229 foreach (self::$types as $type) {
230 if ($only_available && !in_array($type, self::$available_types)) {
233 $obj =
new self($type);
234 $obj->initCachingService();
259 return 'ilStaticCache';
275 if (self::$active_cache[$this->
getComponent()] !==
null) {
290 $isActive = $this->global_cache->isActive();
305 return $this->global_cache->isValid($key);
313 return count(self::getAllInstallableTypes()) > 0;
321 return $this->global_cache->isInstallable();
329 return $this->global_cache->getInstallationFailureReason();
340 if (!$this->global_cache->isActive()) {
344 return $this->global_cache->exists($key);
356 public function set($key, $value, $ttl =
null) {
361 $this->global_cache->setValid($key);
363 return $this->global_cache->set($key, $this->global_cache->serialize($value), $ttl);
373 public function get($key) {
377 $unserialized_return = $this->global_cache->unserialize($this->global_cache->get($key));
378 if ($unserialized_return) {
380 if ($this->global_cache->isValid($key)) {
383 return $unserialized_return;
398 public function delete($key) {
403 return $this->global_cache->delete($key);
413 public function flush($complete =
false) {
414 if ($this->global_cache->isActive()) {
416 return $this->global_cache->flush();
418 $this->global_cache->setInvalid();
427 return $this->global_cache->getInfo();
479 return $this->global_cache->getServiceType();
An exception for terminatinating execution or to throw for unit testing.
Component logger with individual log levels by component id.
Class ilGlobalCacheService.
Class ilGlobalCacheSettings.
setServiceType($service_type)
static setSettings($settings)
static $active_components
getInstallationFailureReason()
static setAvailableComponents($available_components)
static $available_components
isCacheServiceInstallable()
static setup(ilGlobalCacheSettings $ilGlobalCacheSettings)
static lookupServiceClassName($service_type)
static getAllInstallableTypes()
static getAllTypes($only_available=true)
static setActiveComponents($active_components)
static getActiveComponents()
static $unique_service_id
static log($message, $log_level)
__construct($service_type)
static $type_per_component
static getAvailableComponents()
static getInstance($component)
static generateServiceId()