25 global $shmkeys, $shmoffset;
51 'interventions' => 24,
73 if (strpos($memoryid,
'count_') === 0) {
74 if (empty($conf->global->MAIN_CACHE_COUNT)) {
79 if (!empty($conf->memcached->enabled) && class_exists(
'Memcached')) {
82 if (empty($dolmemcache) || !is_object($dolmemcache)) {
83 $dolmemcache =
new Memcached();
84 $tmparray = explode(
':', $conf->global->MEMCACHED_SERVER);
85 $result = $dolmemcache->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211);
91 $memoryid = session_name().
'_'.$memoryid;
93 $dolmemcache->add($memoryid, $data, $expire);
94 $rescode = $dolmemcache->getResultCode();
96 return is_array($data) ? count($data) : (is_scalar($data) ? strlen($data) : 0);
100 } elseif (!empty($conf->memcached->enabled) && class_exists(
'Memcache')) {
103 if (empty($dolmemcache) || !is_object($dolmemcache)) {
104 $dolmemcache =
new Memcache();
105 $tmparray = explode(
':', $conf->global->MEMCACHED_SERVER);
106 $result = $dolmemcache->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211);
112 $memoryid = session_name().
'_'.$memoryid;
114 $result = $dolmemcache->add($memoryid, $data,
false, $expire);
116 return is_array($data) ? count($data) : (is_scalar($data) ? strlen($data) : 0);
120 } elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) {
139 if (strpos($memoryid,
'count_') === 0) {
140 if (empty($conf->global->MAIN_CACHE_COUNT)) {
146 if (!empty($conf->memcached->enabled) && class_exists(
'Memcached')) {
148 if (empty($m) || !is_object($m)) {
149 $m =
new Memcached();
150 $tmparray = explode(
':', $conf->global->MEMCACHED_SERVER);
151 $result = $m->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211);
157 $memoryid = session_name().
'_'.$memoryid;
160 $data = $m->get($memoryid);
161 $rescode = $m->getResultCode();
166 } elseif ($rescode == 16) {
171 } elseif (!empty($conf->memcached->enabled) && class_exists(
'Memcache')) {
173 if (empty($m) || !is_object($m)) {
175 $tmparray = explode(
':', $conf->global->MEMCACHED_SERVER);
176 $result = $m->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211);
182 $memoryid = session_name().
'_'.$memoryid;
184 $data = $m->get($memoryid);
192 } elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) {
211 global $shmkeys, $shmoffset;
212 if (empty($shmkeys[$memoryid])) {
215 return $shmkeys[$memoryid] + $shmoffset;
225 global $shmkeys, $shmoffset;
228 foreach ($shmkeys as $key => $val) {
230 if (!is_numeric($result) || $result > 0) {
231 $resarray[$key] = $result;
247 global $shmkeys, $shmoffset;
250 if (empty($shmkeys[$memoryid]) || !function_exists(
"shmop_write")) {
254 if (empty($shmkey)) {
258 $newdata = serialize($data);
259 $size = strlen($newdata);
261 $handle = shmop_open($shmkey,
'c', 0644, 6 + $size);
263 $shm_bytes_written1 = shmop_write($handle, str_pad($size, 6), 0);
264 $shm_bytes_written2 = shmop_write($handle, $newdata, 6);
265 if (($shm_bytes_written1 + $shm_bytes_written2) != (6 +
dol_strlen($newdata))) {
266 print
"Couldn't write the entire length of data\n";
268 shmop_close($handle);
269 return ($shm_bytes_written1 + $shm_bytes_written2);
271 print
'Error in shmop_open for memoryid='.$memoryid.
' shmkey='.$shmkey.
' 6+size=6+'.$size;
284 global $shmkeys, $shmoffset;
288 if (empty($shmkeys[$memoryid]) || !function_exists(
"shmop_open")) {
292 if (empty($shmkey)) {
297 $handle = @shmop_open($shmkey,
'a', 0, 0);
299 $size = trim(shmop_read($handle, 0, 6));
301 $data = unserialize(shmop_read($handle, 6, $size));
305 shmop_close($handle);
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_setcache($memoryid, $data, $expire=0)
Save data into a memory area shared by all users, all sessions on server.
dol_getcache($memoryid)
Read a memory area shared by all users, all sessions on server.
dol_listshmop()
Return list of contents of all memory area shared.
dol_setshmop($memoryid, $data, $expire)
Save data into a memory area shared by all users, all sessions on server.
dol_getshmopaddress($memoryid)
Return shared memory address used to store dataset with key memoryid.
dol_getshmop($memoryid)
Read a memory area shared by all users, all sessions on server.