ILIAS  release_7 Revision v7.30-3-g800a261c036
ilApc Class Reference

Class ilApc. More...

+ Inheritance diagram for ilApc:
+ Collaboration diagram for ilApc:

Public Member Functions

 exists ($key)
 
 set ($key, $serialized_value, $ttl=0)
 
 get ($key)
 
 delete ($key)
 
 flush ($complete=false)
 
 serialize ($value)
 
 unserialize ($serialized_value)
 
 getInfo ()
 
 isValid ($key)
 Checks whether the cache key is valid or not.This method exists only for legacy reasons and has only a real function in combination with XCache.
Parameters
string$keyThe key which should be checked.
Returns
bool True if the key is valid otherwise false.
More...
 
- Public Member Functions inherited from ilGlobalCacheService
 __construct ($service_id, $component)
 
 unserialize ($serialized_value)
 
 get ($key)
 
 set ($key, $serialized_value, $ttl=null)
 
 serialize ($value)
 
 getServiceId ()
 
 setServiceId ($service_id)
 
 getComponent ()
 
 setComponent ($component)
 
 isActive ()
 
 isInstallable ()
 
 returnKey ($key)
 
 getInfo ()
 
 getInstallationFailureReason ()
 
 exists ($key)
 
 delete ($key)
 
 flush ($complete=false)
 
 setServiceType ($service_type)
 
 getServiceType ()
 
 setValid ($key)
 Declare a key as valid. More...
 
 setInvalid ($key=null)
 Set the key as invalid. More...
 
 isValid ($key)
 Checks whether the cache key is valid or not. More...
 

Data Fields

const MIN_MEMORY = 16
 
const CACHE_ID = 'user'
 

Protected Member Functions

 getActive ()
 
 getInstallable ()
 
 getMemoryLimit ()
 
 getMinMemory ()
 @inheritDoc More...
 
- Protected Member Functions inherited from ilGlobalCacheService
 getActive ()
 
 getInstallable ()
 
 getMemoryLimit ()
 
 getMinMemory ()
 
 checkMemory ()
 

Additional Inherited Members

- Protected Attributes inherited from ilGlobalCacheService
 $current_time = 0
 
 $valid_keys = array()
 
 $service_id = ''
 
 $component = ''
 
 $service_type = ilGlobalCache::TYPE_STATIC
 
 $valid_key_hash = ''
 
- Static Protected Attributes inherited from ilGlobalCacheService
static $active = array()
 
static $installable = array()
 

Detailed Description

Class ilApc.

@beta

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

Definition at line 14 of file class.ilApc.php.

Member Function Documentation

◆ delete()

ilApc::delete (   $key)
Parameters
$key
Returns
bool|string[]

Reimplemented from ilGlobalCacheService.

Definition at line 64 of file class.ilApc.php.

65 {
66 return apcu_delete($this->returnKey($key));
67 }

References ilGlobalCacheService\returnKey().

+ Here is the call graph for this function:

◆ exists()

ilApc::exists (   $key)
Parameters
$key
Returns
bool

Reimplemented from ilGlobalCacheService.

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

26 {
27 if (function_exists('apcu_exists')) {
28 return apcu_exists($this->returnKey($key));
29 } else {
30 return apcu_fetch($this->returnKey($key));
31 }
32 }

References ilGlobalCacheService\returnKey().

+ Here is the call graph for this function:

◆ flush()

ilApc::flush (   $complete = false)
Parameters
bool$complete
Returns
bool

Reimplemented from ilGlobalCacheService.

Definition at line 75 of file class.ilApc.php.

76 {
77 // incomplete flushing is not supported by APCu, an own implementation coused issues like https://mantis.ilias.de/view.php?id=28201
78 return function_exists('apcu_clear_cache') && apcu_clear_cache();
79 }

◆ get()

ilApc::get (   $key)
Parameters
$key
Returns
mixed

Reimplemented from ilGlobalCacheService.

Definition at line 53 of file class.ilApc.php.

54 {
55 return apcu_fetch($this->returnKey($key));
56 }

References ilGlobalCacheService\returnKey().

+ Here is the call graph for this function:

◆ getActive()

ilApc::getActive ( )
protected
Returns
bool

Reimplemented from ilGlobalCacheService.

Definition at line 138 of file class.ilApc.php.

139 {
140 return function_exists('apcu_store');
141 }

◆ getInfo()

ilApc::getInfo ( )
Returns
array

Reimplemented from ilGlobalCacheService.

Definition at line 107 of file class.ilApc.php.

108 {
109 $return = array();
110
111 $cache_info = apc_cache_info();
112
113 unset($cache_info['cache_list']);
114 unset($cache_info['slot_distribution']);
115
116 $return['__cache_info'] = array(
117 'apc.enabled' => ini_get('apc.enabled'),
118 'apc.shm_size' => ini_get('apc.shm_size'),
119 'apc.shm_segments' => ini_get('apc.shm_segments'),
120 'apc.gc_ttl' => ini_get('apc.gc_ttl'),
121 'apc.user_ttl' => ini_get('apc.ttl'),
122 'info' => $cache_info,
123 );
124
125 $cache_info = apc_cache_info();
126 foreach ($cache_info['cache_list'] as $dat) {
127 $key = $dat['key'];
128
129 if (preg_match('/' . $this->getServiceId() . '_' . $this->getComponent() . '/', $key)) {
130 $return[$key] = apc_fetch($key);
131 }
132 }
133
134 return $return;
135 }

References ilGlobalCacheService\getComponent(), and ilGlobalCacheService\getServiceId().

+ Here is the call graph for this function:

◆ getInstallable()

ilApc::getInstallable ( )
protected
Returns
bool

Reimplemented from ilGlobalCacheService.

Definition at line 147 of file class.ilApc.php.

148 {
149 return function_exists('apcu_store');
150 }

◆ getMemoryLimit()

ilApc::getMemoryLimit ( )
protected
Returns
string

Reimplemented from ilGlobalCacheService.

Definition at line 156 of file class.ilApc.php.

157 {
158 if (ilRuntime::getInstance()->isHHVM()) {
159 return $this->getMinMemory() . 'M';
160 }
161
162 return ini_get('apc.shm_size');
163 }
getMinMemory()
@inheritDoc
static getInstance()

References ilRuntime\getInstance(), and getMinMemory().

+ Here is the call graph for this function:

◆ getMinMemory()

ilApc::getMinMemory ( )
protected

@inheritDoc

Reimplemented from ilGlobalCacheService.

Definition at line 169 of file class.ilApc.php.

170 {
171 return self::MIN_MEMORY;
172 }
const MIN_MEMORY
Definition: class.ilApc.php:16

References MIN_MEMORY.

Referenced by getMemoryLimit().

+ Here is the caller graph for this function:

◆ isValid()

ilApc::isValid (   $key)

Checks whether the cache key is valid or not.This method exists only for legacy reasons and has only a real function in combination with XCache.

Parameters
string$keyThe key which should be checked.
Returns
bool True if the key is valid otherwise false.

Reimplemented from ilGlobalCacheService.

Definition at line 178 of file class.ilApc.php.

179 {
180 return true;
181 }

◆ serialize()

ilApc::serialize (   $value)
Parameters
$value
Returns
mixed|string

Reimplemented from ilGlobalCacheService.

Definition at line 87 of file class.ilApc.php.

88 {
89 return ($value);
90 }

◆ set()

ilApc::set (   $key,
  $serialized_value,
  $ttl = 0 
)
Parameters
$key
$serialized_value
int$ttl
Returns
array|bool

Reimplemented from ilGlobalCacheService.

Definition at line 42 of file class.ilApc.php.

43 {
44 return apcu_store($this->returnKey($key), $serialized_value, $ttl);
45 }

References ilGlobalCacheService\returnKey().

+ Here is the call graph for this function:

◆ unserialize()

ilApc::unserialize (   $serialized_value)
Parameters
$serialized_value
Returns
mixed

Reimplemented from ilGlobalCacheService.

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

99 {
100 return ($serialized_value);
101 }

Field Documentation

◆ CACHE_ID

const ilApc::CACHE_ID = 'user'

Definition at line 17 of file class.ilApc.php.

◆ MIN_MEMORY

const ilApc::MIN_MEMORY = 16

Definition at line 16 of file class.ilApc.php.

Referenced by getMinMemory().


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