Пример #1
0
 /**
  * Store cell data in cache for the current cell object if it's "dirty",
  *     and the 'nullify' the current cell object
  *
  * @throws  \PHPExcel\Exception
  */
 protected function storeData()
 {
     if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
         $this->currentObject->detach();
         $obj = serialize($this->currentObject);
         if (!$this->memcache->replace($this->cachePrefix . $this->currentObjectID . '.cache', $obj, null, $this->cacheTime)) {
             if (!$this->memcache->add($this->cachePrefix . $this->currentObjectID . '.cache', $obj, null, $this->cacheTime)) {
                 $this->__destruct();
                 throw new \PHPExcel\Exception("Failed to store cell {$this->currentObjectID} in MemCache");
             }
         }
         $this->currentCellIsDirty = false;
     }
     $this->currentObjectID = $this->currentObject = null;
 }
Пример #2
0
 /**
  * Store cell data in cache for the current cell object if it's "dirty",
  *     and the 'nullify' the current cell object
  *
  * @return	void
  * @throws	PHPExcel_Exception
  */
 protected function _storeData()
 {
     if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
         $this->_currentObject->detach();
         $obj = serialize($this->_currentObject);
         if (!$this->_memcache->replace($this->_cachePrefix . $this->_currentObjectID . '.cache', $obj, NULL, $this->_cacheTime)) {
             if (!$this->_memcache->add($this->_cachePrefix . $this->_currentObjectID . '.cache', $obj, NULL, $this->_cacheTime)) {
                 $this->__destruct();
                 throw new PHPExcel_Exception('Failed to store cell ' . $this->_currentObjectID . ' in MemCache');
             }
         }
         $this->_currentCellIsDirty = false;
     }
     $this->_currentObjectID = $this->_currentObject = null;
 }
Пример #3
0
 /**
  * Writes session data to the memcache based session storage handler
  *
  * @param string $id The ID of the session
  * @param string $value The session data to store
  * @access protected
  */
 protected function _write($id, $value)
 {
     $id = 'sess_' . $id;
     if ($this->_conn->get($id)) {
         return $this->_conn->replace($id, $value, 0, $this->_life_time);
     } else {
         return $this->_conn->set($id, $value, 0, $this->_life_time);
     }
 }
Пример #4
0
 /**
  * Set expire time on each call since memcached sets it on cache creation.
  *
  * @param   string  $key  Cache key to expire.
  *
  * @return  void
  *
  * @since   11.1
  */
 protected function _setExpire($key)
 {
     $lifetime = ini_get("session.gc_maxlifetime");
     $expire = $this->_db->get($key . '_expire');
     // Set prune period
     if ($expire + $lifetime < time()) {
         $this->_db->delete($key);
         $this->_db->delete($key . '_expire');
     } else {
         $this->_db->replace($key . '_expire', time());
     }
 }
Пример #5
0
 /**
  * Set expire time on each call since memcache sets it on cache creation.
  *
  * @access private
  *
  * @param string  $key   Cache key to expire.
  * @param integer $lifetime  Lifetime of the data in seconds.
  */
 function _setExpire($key)
 {
     $lifetime = $this->_lifetime;
     $expire = $this->_db->get($key . '_expire');
     // set prune period
     if ($expire + $lifetime < time()) {
         $this->_db->delete($key);
         $this->_db->delete($key . '_expire');
     } else {
         $this->_db->replace($key . '_expire', time());
     }
 }
Пример #6
0
 /**
  * Clean cache for a group given a mode.
  *
  * group mode		: cleans all cache in the group
  * notgroup mode	: cleans all cache not in the group
  *
  * @access	public
  * @param	string	$group	The cache data group
  * @param	string	$mode	The mode for cleaning cache [group|notgroup]
  * @return	boolean	True on success, false otherwise
  * @since	1.5
  */
 function clean($group, $mode)
 {
     if (!$this->lockindex()) {
         return false;
     }
     $index = $this->_db->get($this->_hash . '-index');
     if ($index === false) {
         $index = array();
     }
     $secret = $this->_hash;
     foreach ($index as $key => $value) {
         if (strpos($value->name, $secret . '-cache-' . $group . '-' . $this->_site) === 0 xor $mode != 'group') {
             $this->_db->delete($value->name, 0);
             unset($index[$key]);
         }
     }
     $this->_db->replace($this->_hash . '-index', $index, 0, 0);
     $this->unlockindex();
     return true;
 }
Пример #7
0
 /**
  * update
  * @param string $key
  * @param string|array|object $value
  * @param int $ttl
  * @param string $tableName
  * @param resource $connectionResource
  * @return boolean
  */
 public function update($key, $value, $ttl = 0, $tableName = '', $connectionResource = null)
 {
     return $connectionResource->replace($this->getRealKey($tableName, $key), $value, $ttl);
 }