2 require_once(
'./Services/GlobalCache/classes/Memcache/class.ilMemcache.php');
3 require_once(
'./Services/GlobalCache/classes/Xcache/class.ilXcache.php');
4 require_once(
'./Services/GlobalCache/classes/Apc/class.ilApc.php');
5 require_once(
'./Services/GlobalCache/classes/Static/class.ilStaticCache.php');
6 require_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,
107 self::setSettings($ilGlobalCacheSettings);
122 $ilGlobalCache->setComponent($component);
123 $ilGlobalCache->initCachingService();
125 self::$instances[
$component] = $ilGlobalCache;
138 self::generateServiceId();
143 protected function initCachingService()
151 $serviceName = self::lookupServiceClassName($this->
getServiceType());
152 $ilGlobalCacheService =
new $serviceName(self::$unique_service_id, $this->
getComponent());
154 $this->global_cache = $ilGlobalCacheService;
162 $ilGlobalCacheSettings =
new ilGlobalCacheSettings();
173 if ($log_level <= self::getSettings()->getLogLevel()) {
176 $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
178 $class = $backtrace[1][
'class'];
191 if (!isset(self::$unique_service_id)) {
194 $rawServiceId .=
'il_' . CLIENT_ID;
196 self::$unique_service_id = substr(md5($rawServiceId), 0, 6);
201 public static function flushAll()
207 foreach (self::$types as
$type) {
208 $serviceName = self::lookupServiceClassName($type);
209 $service =
new $serviceName(self::generateServiceId(),
'flush');
225 foreach (self::getAllTypes() as
$type) {
226 if ($type->isCacheServiceInstallable()) {
242 foreach (self::$types as
$type) {
243 if ($only_available && !in_array($type, self::$available_types)) {
246 $obj =
new self(
$type);
247 $obj->initCachingService();
266 case self::TYPE_MEMCACHED:
269 case self::TYPE_XCACHE:
273 return 'ilStaticCache';
290 if (self::$active_cache[$this->
getComponent()] !== null) {
305 $isActive = $this->global_cache->isActive();
306 self::log(
'component ' . $this->
getComponent() .
', service is active: ' 321 return $this->global_cache->isValid(
$key);
330 return count(self::getAllInstallableTypes()) > 0;
339 return $this->global_cache->isInstallable();
348 return $this->global_cache->getInstallationFailureReason();
360 if (!$this->global_cache->isActive()) {
364 return $this->global_cache->exists(
$key);
376 public function set(
$key, $value, $ttl = null)
382 $this->global_cache->setValid(
$key);
384 return $this->global_cache->set(
$key, $this->global_cache->serialize($value), $ttl);
399 $unserialized_return = $this->global_cache->unserialize($this->global_cache->get(
$key));
400 if ($unserialized_return) {
401 $service_name =
' [' . self::lookupServiceClassName($this->
getServiceType()) .
']';
402 if ($this->global_cache->isValid(
$key)) {
405 return $unserialized_return;
426 return $this->global_cache->delete(
$key);
436 public function flush($complete =
false)
438 if ($this->global_cache->isActive()) {
439 return $this->global_cache->flush();
448 return $this->global_cache->getInfo();
506 return $this->global_cache->getServiceType();
536 return self::$active_components;
554 return self::$available_components;
static setActiveComponents($active_components)
static getAllInstallableTypes()
Class ilGlobalCacheSettings.
static getInstance($component)
static setup(ilGlobalCacheSettings $ilGlobalCacheSettings)
static getAllTypes($only_available=true)
Component logger with individual log levels by component id.
Class ilGlobalCacheService.
setServiceType($service_type)
static generateServiceId()
__construct($service_type)
static $available_components
static lookupServiceClassName($service_type)
static $unique_service_id
catch(Exception $e) $message
isCacheServiceInstallable()
static getAvailableComponents()
static $type_per_component
static $active_components
Create styles array
The data for the language used.
static log($message, $log_level)
getInstallationFailureReason()
static getActiveComponents()
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
static setSettings($settings)
static setAvailableComponents($available_components)