74 if (strpos($memoryid,
'count_') === 0) {
75 if (empty($conf->global->MAIN_CACHE_COUNT)) {
80 if (isModEnabled(
'memcached') && class_exists(
'Memcached')) {
83 if (empty($dolmemcache) || !is_object($dolmemcache)) {
84 $dolmemcache =
new Memcached();
85 $tmparray = explode(
':', $conf->global->MEMCACHED_SERVER);
86 $result = $dolmemcache->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211);
92 $memoryid = session_name().
'_'.$memoryid;
94 $dolmemcache->add($memoryid, $data, $expire);
95 $rescode = $dolmemcache->getResultCode();
97 return is_array($data) ? count($data) : (is_scalar($data) ? strlen($data) : 0);
101 } elseif (isModEnabled(
'memcached') && class_exists(
'Memcache')) {
104 if (empty($dolmemcache) || !is_object($dolmemcache)) {
105 $dolmemcache =
new Memcache();
106 $tmparray = explode(
':', $conf->global->MEMCACHED_SERVER);
107 $result = $dolmemcache->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211);
113 $memoryid = session_name().
'_'.$memoryid;
115 $result = $dolmemcache->add($memoryid, $data,
false, $expire);
117 return is_array($data) ? count($data) : (is_scalar($data) ? strlen($data) : 0);
121 } elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) {
126 $conf->cache[
'cachememory_'.$memoryid] = $data;
127 $result = is_array($data) ? count($data) : (is_scalar($data) ? strlen($data) : 0);
144 if (strpos($memoryid,
'count_') === 0) {
145 if (empty($conf->global->MAIN_CACHE_COUNT)) {
151 if (isModEnabled(
'memcached') && class_exists(
'Memcached')) {
153 if (empty($m) || !is_object($m)) {
154 $m =
new Memcached();
155 $tmparray = explode(
':', $conf->global->MEMCACHED_SERVER);
156 $result = $m->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211);
162 $memoryid = session_name().
'_'.$memoryid;
165 $data = $m->get($memoryid);
166 $rescode = $m->getResultCode();
171 } elseif ($rescode == 16) {
176 } elseif (isModEnabled(
'memcached') && class_exists(
'Memcache')) {
178 if (empty($m) || !is_object($m)) {
180 $tmparray = explode(
':', $conf->global->MEMCACHED_SERVER);
181 $result = $m->addServer($tmparray[0], $tmparray[1] ? $tmparray[1] : 11211);
187 $memoryid = session_name().
'_'.$memoryid;
189 $data = $m->get($memoryid);
197 } elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02)) {
203 if (isset($conf->cache[
'cachememory_'.$memoryid])) {
204 return $conf->cache[
'cachememory_'.$memoryid];
257 global $shmkeys, $shmoffset;
260 if (empty($shmkeys[$memoryid]) || !function_exists(
"shmop_write")) {
264 if (empty($shmkey)) {
268 $newdata = serialize($data);
269 $size = strlen($newdata);
271 $handle = shmop_open($shmkey,
'c', 0644, 6 + $size);
273 $shm_bytes_written1 = shmop_write($handle, str_pad($size, 6), 0);
274 $shm_bytes_written2 = shmop_write($handle, $newdata, 6);
275 if (($shm_bytes_written1 + $shm_bytes_written2) != (6 +
dol_strlen($newdata))) {
276 print
"Couldn't write the entire length of data\n";
278 shmop_close($handle);
279 return ($shm_bytes_written1 + $shm_bytes_written2);
281 print
'Error in shmop_open for memoryid='.$memoryid.
' shmkey='.$shmkey.
' 6+size=6+'.$size;
294 global $shmkeys, $shmoffset;
298 if (empty($shmkeys[$memoryid]) || !function_exists(
"shmop_open")) {
302 if (empty($shmkey)) {
307 $handle = @shmop_open($shmkey,
'a', 0, 0);
309 $size = trim(shmop_read($handle, 0, 6));
311 $data = unserialize(shmop_read($handle, 6, $size));
315 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.