Пример #1
0
 /**
  * Adds entry into memcache/apc DB.
  *
  * @param string  $key   Cache key name
  * @param mxied   $data  Serialized cache data
  * @param bollean $index Enables immediate index update
  *
  * @param boolean True on success, False on failure
  */
 private function add_record($key, $data, $index = false)
 {
     if ($this->type == 'memcache') {
         $result = $this->db->replace($key, $data, MEMCACHE_COMPRESSED, $this->ttl);
         if (!$result) {
             $result = $this->db->set($key, $data, MEMCACHE_COMPRESSED, $this->ttl);
         }
     } else {
         if ($this->type == 'apc') {
             if (apc_exists($key)) {
                 apc_delete($key);
             }
             $result = apc_store($key, $data, $this->ttl);
         }
     }
     // Update index
     if ($index && $result) {
         $this->load_index();
         if (array_search($key, $this->index) === false) {
             $this->index[] = $key;
             $data = serialize($this->index);
             $this->add_record($this->ikey(), $data);
         }
     }
     return $result;
 }
Пример #2
0
 /**
  * Adds entry into memcache/apc DB.
  *
  * @param string $key  Cache key name
  * @param mixed  $data Serialized cache data
  *
  * @param boolean True on success, False on failure
  */
 private function add_record($key, $data)
 {
     if ($this->type == 'memcache') {
         $result = $this->db->replace($key, $data, MEMCACHE_COMPRESSED, $this->ttl);
         if (!$result) {
             $result = $this->db->set($key, $data, MEMCACHE_COMPRESSED, $this->ttl);
         }
     } else {
         if ($this->type == 'apc') {
             if (apc_exists($key)) {
                 apc_delete($key);
             }
             $result = apc_store($key, $data, $this->ttl);
         }
     }
     return $result;
 }