ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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)
 
- 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 ()
 
- 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.

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[]

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

References ilGlobalCacheService\returnKey().

65  {
66  return apcu_delete($this->returnKey($key));
67  }
+ Here is the call graph for this function:

◆ exists()

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

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

References ilGlobalCacheService\returnKey().

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  }
+ Here is the call graph for this function:

◆ flush()

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

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

76  {
77  // incomplete flushing is not supported by APCu, an own implementation caused 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

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

References ilGlobalCacheService\returnKey().

54  {
55  return apcu_fetch($this->returnKey($key));
56  }
+ Here is the call graph for this function:

◆ getActive()

ilApc::getActive ( )
protected

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

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

◆ getInfo()

ilApc::getInfo ( )
Returns
array

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

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

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  }
+ Here is the call graph for this function:

◆ getInstallable()

ilApc::getInstallable ( )
protected
Returns
bool

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

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

◆ getMemoryLimit()

ilApc::getMemoryLimit ( )
protected
Returns
string

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

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

157  {
158  if (ilRuntime::getInstance()->isHHVM()) {
159  return $this->getMinMemory() . 'M';
160  }
161 
162  return ini_get('apc.shm_size');
163  }
static getInstance()
getMinMemory()
+ Here is the call graph for this function:

◆ getMinMemory()

ilApc::getMinMemory ( )
protected

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

Referenced by getMemoryLimit().

170  {
171  return self::MIN_MEMORY;
172  }
+ Here is the caller graph for this function:

◆ isValid()

ilApc::isValid (   $key)

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

179  {
180  return true;
181  }

◆ serialize()

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

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

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

References ilGlobalCacheService\returnKey().

43  {
44  return apcu_store($this->returnKey($key), $serialized_value, $ttl);
45  }
+ Here is the call graph for this function:

◆ unserialize()

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

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.


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