ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
PHPExcel_CachedObjectStorage_Memcache Class Reference
+ Inheritance diagram for PHPExcel_CachedObjectStorage_Memcache:
+ Collaboration diagram for PHPExcel_CachedObjectStorage_Memcache:

Public Member Functions

 addCacheData ($pCoord, PHPExcel_Cell $cell)
 Add or Update a cell in cache identified by coordinate address. More...
 
 isDataSet ($pCoord)
 Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? More...
 
 getCacheData ($pCoord)
 Get cell at a specific coordinate. More...
 
 getCellList ()
 Get a list of all cell addresses currently held in cache. More...
 
 deleteCacheData ($pCoord)
 Delete a cell in cache identified by coordinate address. More...
 
 copyCellCollection (PHPExcel_Worksheet $parent)
 Clone the cell collection. More...
 
 unsetWorksheetCells ()
 Clear the cell collection and disconnect from our parent. More...
 
 __construct (PHPExcel_Worksheet $parent, $arguments)
 Initialise this new cell collection. More...
 
 failureCallback ($host, $port)
 
 __destruct ()
 Destroy this cell collection. More...
 
- Public Member Functions inherited from PHPExcel_CachedObjectStorage_CacheBase
 __construct (PHPExcel_Worksheet $parent)
 Initialise this new cell collection. More...
 
 getParent ()
 Return the parent worksheet for this cell collection. More...
 
 isDataSet ($pCoord)
 Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? More...
 
 moveCell ($fromAddress, $toAddress)
 Move a cell object from one address to another. More...
 
 updateCacheData (PHPExcel_Cell $cell)
 Add or Update a cell in cache. More...
 
 deleteCacheData ($pCoord)
 Delete a cell in cache identified by coordinate address. More...
 
 getCellList ()
 Get a list of all cell addresses currently held in cache. More...
 
 getSortedCellList ()
 Sort the list of all cell addresses currently held in cache by row and column. More...
 
 getHighestRowAndColumn ()
 Get highest worksheet column and highest row that have cell records. More...
 
 getCurrentAddress ()
 Return the cell address of the currently active cell object. More...
 
 getCurrentColumn ()
 Return the column address of the currently active cell object. More...
 
 getCurrentRow ()
 Return the row address of the currently active cell object. More...
 
 getHighestColumn ($row=null)
 
 getHighestRow ($column=null)
 
 copyCellCollection (PHPExcel_Worksheet $parent)
 Clone the cell collection. More...
 
 removeRow ($row)
 Remove a row, deleting all cells in that row. More...
 
 removeColumn ($column)
 Remove a column, deleting all cells in that column. More...
 
- Public Member Functions inherited from PHPExcel_CachedObjectStorage_ICache
 addCacheData ($pCoord, PHPExcel_Cell $cell)
 Add or Update a cell in cache identified by coordinate address. More...
 
 updateCacheData (PHPExcel_Cell $cell)
 Add or Update a cell in cache. More...
 
 getCacheData ($pCoord)
 Fetch a cell from cache identified by coordinate address. More...
 
 deleteCacheData ($pCoord)
 Delete a cell in cache identified by coordinate address. More...
 
 isDataSet ($pCoord)
 Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell? More...
 
 getCellList ()
 Get a list of all cell addresses currently held in cache. More...
 
 getSortedCellList ()
 Get the list of all cell addresses currently held in cache sorted by column and row. More...
 
 copyCellCollection (PHPExcel_Worksheet $parent)
 Clone the cell collection. More...
 

Static Public Member Functions

static cacheMethodIsAvailable ()
 Identify whether the caching method is currently available Some methods are dependent on the availability of certain extensions being enabled in the PHP build. More...
 
static cacheMethodIsAvailable ()
 Identify whether the caching method is currently available Some methods are dependent on the availability of certain extensions being enabled in the PHP build. More...
 
static cacheMethodIsAvailable ()
 Identify whether the caching method is currently available Some methods are dependent on the availability of certain extensions being enabled in the PHP build. More...
 

Protected Member Functions

 _storeData ()
 Store cell data in cache for the current cell object if it's "dirty", and the 'nullify' the current cell object. More...
 
- Protected Member Functions inherited from PHPExcel_CachedObjectStorage_CacheBase
 _getUniqueID ()
 Generate a unique ID for cache referencing. More...
 

Private Attributes

 $_cachePrefix = null
 
 $_cacheTime = 600
 
 $_memcache = null
 

Additional Inherited Members

- Protected Attributes inherited from PHPExcel_CachedObjectStorage_CacheBase
 $_parent
 
 $_currentObject = null
 
 $_currentObjectID = null
 
 $_currentCellIsDirty = true
 
 $_cellCache = array()
 

Detailed Description

Definition at line 36 of file Memcache.php.

Constructor & Destructor Documentation

◆ __construct()

PHPExcel_CachedObjectStorage_Memcache::__construct ( PHPExcel_Worksheet  $parent,
  $arguments 
)

Initialise this new cell collection.

Parameters
PHPExcel_Worksheet$parentThe worksheet for this cell collection
arrayof mixed $arguments Additional initialisation arguments

Definition at line 255 of file Memcache.php.

255 {
256 $memcacheServer = (isset($arguments['memcacheServer'])) ? $arguments['memcacheServer'] : 'localhost';
257 $memcachePort = (isset($arguments['memcachePort'])) ? $arguments['memcachePort'] : 11211;
258 $cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
259
260 if (is_null($this->_cachePrefix)) {
261 $baseUnique = $this->_getUniqueID();
262 $this->_cachePrefix = substr(md5($baseUnique),0,8).'.';
263
264 // Set a new Memcache object and connect to the Memcache server
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);
268 }
269 $this->_cacheTime = $cacheTime;
270
271 parent::__construct($parent);
272 }
273 } // function __construct()
_getUniqueID()
Generate a unique ID for cache referencing.
Definition: CacheBase.php:311

References PHPExcel_CachedObjectStorage_CacheBase\_getUniqueID().

+ Here is the call graph for this function:

◆ __destruct()

PHPExcel_CachedObjectStorage_Memcache::__destruct ( )

Destroy this cell collection.

Definition at line 291 of file Memcache.php.

291 {
292 $cacheList = $this->getCellList();
293 foreach($cacheList as $cellID) {
294 $this->_memcache->delete($this->_cachePrefix.$cellID.'.cache');
295 }
296 } // function __destruct()
getCellList()
Get a list of all cell addresses currently held in cache.
Definition: Memcache.php:174

References getCellList().

Referenced by _storeData(), copyCellCollection(), and unsetWorksheetCells().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Function Documentation

◆ _storeData()

PHPExcel_CachedObjectStorage_Memcache::_storeData ( )
protected

Store cell data in cache for the current cell object if it's "dirty", and the 'nullify' the current cell object.

Returns
void
Exceptions
PHPExcel_Exception

Definition at line 67 of file Memcache.php.

67 {
68 if ($this->_currentCellIsDirty && !empty($this->_currentObjectID)) {
69 $this->_currentObject->detach();
70
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)) {
74 $this->__destruct();
75 throw new PHPExcel_Exception('Failed to store cell '.$this->_currentObjectID.' in MemCache');
76 }
77 }
78 $this->_currentCellIsDirty = false;
79 }
80 $this->_currentObjectID = $this->_currentObject = null;
81 } // function _storeData()
__destruct()
Destroy this cell collection.
Definition: Memcache.php:291

References __destruct().

Referenced by addCacheData(), getCacheData(), and getCellList().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addCacheData()

PHPExcel_CachedObjectStorage_Memcache::addCacheData (   $pCoord,
PHPExcel_Cell  $cell 
)

Add or Update a cell in cache identified by coordinate address.

Parameters
string$pCoordCoordinate address of the cell to update
PHPExcel_Cell$cellCell to update
Returns
PHPExcel_Cell
Exceptions
PHPExcel_Exception

Implements PHPExcel_CachedObjectStorage_ICache.

Definition at line 92 of file Memcache.php.

92 {
93 if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
94 $this->_storeData();
95 }
96 $this->_cellCache[$pCoord] = true;
97
98 $this->_currentObjectID = $pCoord;
99 $this->_currentObject = $cell;
100 $this->_currentCellIsDirty = true;
101
102 return $cell;
103 } // function addCacheData()
_storeData()
Store cell data in cache for the current cell object if it's "dirty", and the 'nullify' the current c...
Definition: Memcache.php:67

References _storeData().

+ Here is the call graph for this function:

◆ cacheMethodIsAvailable()

static PHPExcel_CachedObjectStorage_Memcache::cacheMethodIsAvailable ( )
static

Identify whether the caching method is currently available Some methods are dependent on the availability of certain extensions being enabled in the PHP build.

Returns
boolean

Reimplemented from PHPExcel_CachedObjectStorage_CacheBase.

Definition at line 304 of file Memcache.php.

304 {
305 if (!function_exists('memcache_add')) {
306 return false;
307 }
308
309 return true;
310 }

◆ copyCellCollection()

PHPExcel_CachedObjectStorage_Memcache::copyCellCollection ( PHPExcel_Worksheet  $parent)

Clone the cell collection.

Parameters
PHPExcel_Worksheet$parentThe new worksheet
Returns
void

Reimplemented from PHPExcel_CachedObjectStorage_CacheBase.

Definition at line 204 of file Memcache.php.

204 {
205 parent::copyCellCollection($parent);
206 // Get a new id for the new file name
207 $baseUnique = $this->_getUniqueID();
208 $newCachePrefix = substr(md5($baseUnique),0,8).'.';
209 $cacheList = $this->getCellList();
210 foreach($cacheList as $cellID) {
211 if ($cellID != $this->_currentObjectID) {
212 $obj = $this->_memcache->get($this->_cachePrefix.$cellID.'.cache');
213 if ($obj === false) {
214 // Entry no longer exists in Memcache, so clear it from the cache array
215 parent::deleteCacheData($cellID);
216 throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in MemCache');
217 }
218 if (!$this->_memcache->add($newCachePrefix.$cellID.'.cache',$obj,NULL,$this->_cacheTime)) {
219 $this->__destruct();
220 throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in MemCache');
221 }
222 }
223 }
224 $this->_cachePrefix = $newCachePrefix;
225 } // function copyCellCollection()

References __destruct(), PHPExcel_CachedObjectStorage_CacheBase\_getUniqueID(), and getCellList().

+ Here is the call graph for this function:

◆ deleteCacheData()

PHPExcel_CachedObjectStorage_Memcache::deleteCacheData (   $pCoord)

Delete a cell in cache identified by coordinate address.

Parameters
string$pCoordCoordinate address of the cell to delete
Exceptions
PHPExcel_Exception

Reimplemented from PHPExcel_CachedObjectStorage_CacheBase.

Definition at line 189 of file Memcache.php.

189 {
190 // Delete the entry from Memcache
191 $this->_memcache->delete($this->_cachePrefix.$pCoord.'.cache');
192
193 // Delete the entry from our cell address array
194 parent::deleteCacheData($pCoord);
195 } // function deleteCacheData()

◆ failureCallback()

PHPExcel_CachedObjectStorage_Memcache::failureCallback (   $host,
  $port 
)
Memcache error handler

@param      string  $host           Memcache server
@param      integer $port           Memcache port
Exceptions
PHPExcel_Exception

Definition at line 283 of file Memcache.php.

283 {
284 throw new PHPExcel_Exception('memcache '.$host.':'.$port.' failed');
285 }

◆ getCacheData()

PHPExcel_CachedObjectStorage_Memcache::getCacheData (   $pCoord)

Get cell at a specific coordinate.

Parameters
string$pCoordCoordinate of the cell
Exceptions
PHPExcel_Exception
Returns
PHPExcel_Cell Cell that was found, or null if not found

Implements PHPExcel_CachedObjectStorage_ICache.

Definition at line 139 of file Memcache.php.

139 {
140 if ($pCoord === $this->_currentObjectID) {
142 }
143 $this->_storeData();
144
145 // Check if the entry that has been requested actually exists
146 if (parent::isDataSet($pCoord)) {
147 $obj = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');
148 if ($obj === false) {
149 // Entry no longer exists in Memcache, so clear it from the cache array
150 parent::deleteCacheData($pCoord);
151 throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in MemCache');
152 }
153 } else {
154 // Return null if requested entry doesn't exist in cache
155 return null;
156 }
157
158 // Set current entry to the requested entry
159 $this->_currentObjectID = $pCoord;
160 $this->_currentObject = unserialize($obj);
161 // Re-attach this as the cell's parent
162 $this->_currentObject->attach($this);
163
164 // Return requested entry
166 } // function getCacheData()

References PHPExcel_CachedObjectStorage_CacheBase\$_currentObject, and _storeData().

+ Here is the call graph for this function:

◆ getCellList()

PHPExcel_CachedObjectStorage_Memcache::getCellList ( )

Get a list of all cell addresses currently held in cache.

Returns
string[]

Reimplemented from PHPExcel_CachedObjectStorage_CacheBase.

Definition at line 174 of file Memcache.php.

174 {
175 if ($this->_currentObjectID !== null) {
176 $this->_storeData();
177 }
178
179 return parent::getCellList();
180 }

References _storeData().

Referenced by __destruct(), and copyCellCollection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isDataSet()

PHPExcel_CachedObjectStorage_Memcache::isDataSet (   $pCoord)

Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?

Parameters
string$pCoordCoordinate address of the cell to check
Returns
boolean
boolean

Reimplemented from PHPExcel_CachedObjectStorage_CacheBase.

Definition at line 113 of file Memcache.php.

113 {
114 // Check if the requested entry is the current object, or exists in the cache
115 if (parent::isDataSet($pCoord)) {
116 if ($this->_currentObjectID == $pCoord) {
117 return true;
118 }
119 // Check if the requested entry still exists in Memcache
120 $success = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');
121 if ($success === false) {
122 // Entry no longer exists in Memcache, so clear it from the cache array
123 parent::deleteCacheData($pCoord);
124 throw new PHPExcel_Exception('Cell entry '.$pCoord.' no longer exists in MemCache');
125 }
126 return true;
127 }
128 return false;
129 } // function isDataSet()
$success
Definition: Utf8Test.php:86

References $success.

◆ unsetWorksheetCells()

PHPExcel_CachedObjectStorage_Memcache::unsetWorksheetCells ( )

Clear the cell collection and disconnect from our parent.

Returns
void

Definition at line 233 of file Memcache.php.

233 {
234 if(!is_null($this->_currentObject)) {
235 $this->_currentObject->detach();
236 $this->_currentObject = $this->_currentObjectID = null;
237 }
238
239 // Flush the Memcache cache
240 $this->__destruct();
241
242 $this->_cellCache = array();
243
244 // detach ourself from the worksheet, so that it can then delete this object successfully
245 $this->_parent = null;
246 } // function unsetWorksheetCells()

References __destruct().

+ Here is the call graph for this function:

Field Documentation

◆ $_cachePrefix

PHPExcel_CachedObjectStorage_Memcache::$_cachePrefix = null
private

Definition at line 43 of file Memcache.php.

◆ $_cacheTime

PHPExcel_CachedObjectStorage_Memcache::$_cacheTime = 600
private

Definition at line 50 of file Memcache.php.

◆ $_memcache

PHPExcel_CachedObjectStorage_Memcache::$_memcache = null
private

Definition at line 57 of file Memcache.php.


The documentation for this class was generated from the following file: