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');
15 const MSG =
'Global Cache not active, can not access cache';
64 self::COMP_TPL_BLOCKS,
65 self::COMP_TPL_VARIABLES,
67 self::COMP_GLOBAL_SCREEN,
121 $ilGlobalCache->initCachingService();
123 self::$instances[
$component] = $ilGlobalCache;
139 protected function initCachingService()
148 $ilGlobalCacheService =
new $serviceName(self::$unique_service_id, $this->
getComponent());
150 $this->global_cache = $ilGlobalCacheService;
167 if ($log_level <= self::getSettings()->getLogLevel()) {
169 $ilLog =
$DIC[
'ilLog'];
170 $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
171 $function = $backtrace[1][
'function'];
172 $class = $backtrace[1][
'class'];
174 $ilLog->alert($class .
'::' . $function .
'(): ' .
$message);
184 if (!isset(self::$unique_service_id)) {
186 if (defined(
'CLIENT_ID')) {
189 self::$unique_service_id = substr(md5($rawServiceId), 0, 6);
193 public static function flushAll()
199 foreach (self::$types as
$type) {
201 $service =
new $serviceName(self::generateServiceId(),
'flush');
216 foreach (self::getAllTypes() as
$type) {
217 if (
$type->isCacheServiceInstallable()) {
232 foreach (self::$types as
$type) {
233 if ($only_available && !in_array(
$type, self::$available_types)) {
236 $obj =
new self(
$type);
237 $obj->initCachingService();
250 return ilMemcache::class;
252 return ilXcache::class;
254 return ilStaticCache::class;
283 if (isset(self::$active_cache[
$c]) && self::$active_cache[
$c] !==
null) {
284 return self::$active_cache[
$c];
287 self::$active_cache[
$c] =
false;
293 self::$active_cache[
$c] =
false;
298 $isActive = $this->global_cache->isActive();
299 self::log(
'component ' .
$c .
', service is active: '
301 self::$active_cache[
$c] = $isActive;
312 return $this->global_cache->isValid($key);
320 return count(self::getAllInstallableTypes()) > 0;
328 return $this->global_cache->isInstallable();
336 return $this->global_cache->getInstallationFailureReason();
346 if (!$this->global_cache->isActive()) {
350 return $this->global_cache->exists($key);
360 public function set($key, $value, $ttl =
null)
366 $this->global_cache->setValid($key);
368 return $this->global_cache->set($key, $this->global_cache->serialize($value), $ttl);
376 public function get($key)
381 $unserialized_return = $this->global_cache->unserialize($this->global_cache->get($key));
382 if ($unserialized_return) {
384 if ($this->global_cache->isValid($key)) {
387 return $unserialized_return;
400 public function delete($key)
406 return $this->global_cache->delete($key);
414 public function flush($complete =
false)
416 if ($this->global_cache->isActive()) {
417 return $this->global_cache->flush($complete);
425 return $this->global_cache->getInfo();
477 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 lookupServiceConfigName(int $service_type)
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()