75 if (strpos($memoryid,
'count_') === 0) {
81 if (isModEnabled(
'memcached') && class_exists(
'Memcached')) {
84 if (empty($dolmemcache) || !is_object($dolmemcache)) {
85 $dolmemcache =
new Memcached();
87 $port = (empty($tmparray[1]) ? 0 : $tmparray[1]);
88 $result = $dolmemcache->addServer($tmparray[0], ($port || strpos($tmparray[0],
'/') !==
false) ? $port : 11211);
94 $memoryid = session_name().
'_'.$memoryid;
96 $dolmemcache->add($memoryid, $data, $expire);
97 $rescode = $dolmemcache->getResultCode();
99 return is_array($data) ? count($data) : (is_scalar($data) ? strlen($data) : 0);
103 } elseif (isModEnabled(
'memcached') && class_exists(
'Memcache')) {
106 if (empty($dolmemcache) || !is_object($dolmemcache)) {
107 $dolmemcache =
new Memcache();
109 $port = (empty($tmparray[1]) ? 0 : $tmparray[1]);
110 $result = $dolmemcache->addServer($tmparray[0], ($port || strpos($tmparray[0],
'/') !==
false) ? $port : 11211);
116 $memoryid = session_name().
'_'.$memoryid;
118 $result = $dolmemcache->add($memoryid, $data, 0, $expire);
120 return is_array($data) ? count($data) : (is_scalar($data) ? strlen($data) : 0);
129 $conf->cache[
'cachememory_'.$memoryid] = $data;
130 $result = is_array($data) ? count($data) : (is_scalar($data) ? strlen($data) : 0);
147 if (strpos($memoryid,
'count_') === 0) {
154 if (isModEnabled(
'memcached') && class_exists(
'Memcached')) {
156 if (empty($m) || !is_object($m)) {
157 $m =
new Memcached();
159 $port = (empty($tmparray[1]) ? 0 : $tmparray[1]);
160 $result = $m->addServer($tmparray[0], ($port || strpos($tmparray[0],
'/') !==
false) ? $port : 11211);
166 $memoryid = session_name().
'_'.$memoryid;
169 $data = $m->get($memoryid);
170 $rescode = $m->getResultCode();
175 } elseif ($rescode == 16) {
180 } elseif (isModEnabled(
'memcached') && class_exists(
'Memcache')) {
182 if (empty($m) || !is_object($m)) {
185 $port = (empty($tmparray[1]) ? 0 : $tmparray[1]);
186 $result = $m->addServer($tmparray[0], ($port || strpos($tmparray[0],
'/') !==
false) ? $port : 11211);
192 $memoryid = session_name().
'_'.$memoryid;
194 $data = $m->get($memoryid);
208 if (isset($conf->cache[
'cachememory_'.$memoryid])) {
209 return $conf->cache[
'cachememory_'.$memoryid];
262 global $shmkeys, $shmoffset;
265 if (empty($shmkeys[$memoryid]) || !function_exists(
"shmop_write")) {
269 if (empty($shmkey)) {
273 $newdata = serialize($data);
274 $size = strlen($newdata);
276 $handle = shmop_open($shmkey,
'c', 0644, 6 + $size);
278 $shm_bytes_written1 = shmop_write($handle, str_pad((
string) $size, 6), 0);
279 $shm_bytes_written2 = shmop_write($handle, $newdata, 6);
280 if ($shm_bytes_written1 + $shm_bytes_written2 != 6 +
dol_strlen($newdata)) {
281 print
"Couldn't write the entire length of data\n";
284 shmop_close($handle);
285 return ($shm_bytes_written1 + $shm_bytes_written2);
287 print
'Error in shmop_open for memoryid='.$memoryid.
' shmkey='.$shmkey.
' 6+size=6+'.$size;
300 global $shmkeys, $shmoffset;
304 if (empty($shmkeys[$memoryid]) || !function_exists(
"shmop_open")) {
308 if (empty($shmkey)) {
313 $handle = @shmop_open($shmkey,
'a', 0, 0);
315 $size = (int) trim(shmop_read($handle, 0, 6));
317 $data = unserialize(shmop_read($handle, 6, $size));
322 shmop_close($handle);
dol_setcache($memoryid, $data, $expire=0)
Save data into a memory area shared by all users, all sessions on server.
dol_setshmop($memoryid, $data, $expire)
Save data into a memory area shared by all users, all sessions on server.