68 if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
69 $this->_currentObject->detach();
71 $obj = serialize($this->_currentObject);
72 if (!$this->_memcache->replace($this->_cachePrefix.$this->_currentObjectID.
'.cache',$obj,NULL,$this->_cacheTime)) {
73 if (!$this->_memcache->add($this->_cachePrefix.$this->_currentObjectID.
'.cache',$obj,NULL,$this->_cacheTime)) {
75 throw new PHPExcel_Exception(
'Failed to store cell '.$this->_currentObjectID.
' in MemCache');
78 $this->_currentCellIsDirty =
false;
80 $this->_currentObjectID = $this->_currentObject = null;
93 if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
96 $this->_cellCache[$pCoord] =
true;
98 $this->_currentObjectID = $pCoord;
99 $this->_currentObject = $cell;
100 $this->_currentCellIsDirty =
true;
115 if (parent::isDataSet($pCoord)) {
116 if ($this->_currentObjectID == $pCoord) {
120 $success = $this->_memcache->get($this->_cachePrefix.$pCoord.
'.cache');
123 parent::deleteCacheData($pCoord);
140 if ($pCoord === $this->_currentObjectID) {
146 if (parent::isDataSet($pCoord)) {
147 $obj = $this->_memcache->get($this->_cachePrefix.$pCoord.
'.cache');
148 if ($obj ===
false) {
150 parent::deleteCacheData($pCoord);
159 $this->_currentObjectID = $pCoord;
160 $this->_currentObject = unserialize($obj);
162 $this->_currentObject->attach($this);
175 if ($this->_currentObjectID !== null) {
179 return parent::getCellList();
191 $this->_memcache->delete($this->_cachePrefix.$pCoord.
'.cache');
194 parent::deleteCacheData($pCoord);
205 parent::copyCellCollection($parent);
208 $newCachePrefix = substr(md5($baseUnique),0,8).
'.';
210 foreach($cacheList as $cellID) {
211 if ($cellID != $this->_currentObjectID) {
212 $obj = $this->_memcache->get($this->_cachePrefix.$cellID.
'.cache');
213 if ($obj ===
false) {
215 parent::deleteCacheData($cellID);
218 if (!$this->_memcache->add($newCachePrefix.$cellID.
'.cache',$obj,NULL,$this->_cacheTime)) {
224 $this->_cachePrefix = $newCachePrefix;
234 if(!is_null($this->_currentObject)) {
235 $this->_currentObject->detach();
236 $this->_currentObject = $this->_currentObjectID = null;
242 $this->_cellCache =
array();
245 $this->_parent = null;
256 $memcacheServer = (isset($arguments[
'memcacheServer'])) ? $arguments[
'memcacheServer'] :
'localhost';
257 $memcachePort = (isset($arguments[
'memcachePort'])) ? $arguments[
'memcachePort'] : 11211;
258 $cacheTime = (isset($arguments[
'cacheTime'])) ? $arguments[
'cacheTime'] : 600;
260 if (is_null($this->_cachePrefix)) {
262 $this->_cachePrefix = substr(md5($baseUnique),0,8).
'.';
265 $this->_memcache =
new Memcache();
266 if (!$this->_memcache->addServer($memcacheServer, $memcachePort,
false, 50, 5, 5,
true,
array($this,
'failureCallback'))) {
267 throw new PHPExcel_Exception(
'Could not connect to MemCache server at '.$memcacheServer.
':'.$memcachePort);
269 $this->_cacheTime = $cacheTime;
271 parent::__construct($parent);
293 foreach($cacheList as $cellID) {
294 $this->_memcache->delete($this->_cachePrefix.$cellID.
'.cache');
305 if (!function_exists(
'memcache_add')) {
getCacheData($pCoord)
Get cell at a specific coordinate.
unsetWorksheetCells()
Clear the cell collection and disconnect from our parent.
__destruct()
Destroy this cell collection.
__construct(PHPExcel_Worksheet $parent, $arguments)
Initialise this new cell collection.
static cacheMethodIsAvailable()
Identify whether the caching method is currently available Some methods are dependent on the availabi...
copyCellCollection(PHPExcel_Worksheet $parent)
Clone the cell collection.
getCellList()
Get a list of all cell addresses currently held in cache.
_getUniqueID()
Generate a unique ID for cache referencing.
_storeData()
Store cell data in cache for the current cell object if it's "dirty", and the 'nullify' the current c...
failureCallback($host, $port)
Memcache error handler.
Create styles array
The data for the language used.
deleteCacheData($pCoord)
Delete a cell in cache identified by coordinate address.
addCacheData($pCoord, PHPExcel_Cell $cell)
Add or Update a cell in cache identified by coordinate address.
isDataSet($pCoord)
Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?