ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
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.
 isDataSet ($pCoord)
 Is a value set in the current PHPExcel_CachedObjectStorage_ICache for an indexed cell?
 getCacheData ($pCoord)
 Get cell at a specific coordinate.
 deleteCacheData ($pCoord)
 Delete a cell in cache identified by coordinate address.
 copyCellCollection (PHPExcel_Worksheet $parent)
 Clone the cell collection.
 unsetWorksheetCells ()
 __construct (PHPExcel_Worksheet $parent, $arguments)
 failureCallback ($host, $port)
 __destruct ()
- Public Member Functions inherited from PHPExcel_CachedObjectStorage_CacheBase
 __construct (PHPExcel_Worksheet $parent)
 updateCacheData (PHPExcel_Cell $cell)
 Add or Update a cell in cache.
 getCellList ()
 Get a list of all cell addresses currently held in cache.
 getSortedCellList ()
 Sort the list of all cell addresses currently held in cache by row and column.
- Public Member Functions inherited from PHPExcel_CachedObjectStorage_ICache
 updateCacheData (PHPExcel_Cell $cell)
 Add or Update a cell in cache.
 getCellList ()
 Get a list of all cell addresses currently held in cache.
 getSortedCellList ()
 Get the list of all cell addresses currently held in cache sorted by column and row.

Private Member Functions

 _storeData ()

Private Attributes

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

Additional Inherited Members

- Protected Member Functions inherited from PHPExcel_CachedObjectStorage_CacheBase
 _getUniqueID ()
- Protected Attributes inherited from PHPExcel_CachedObjectStorage_CacheBase
 $_parent
 $_currentObject = null
 $_currentObjectID = null
 $_cellCache = array()

Detailed Description

Definition at line 36 of file Memcache.php.

Constructor & Destructor Documentation

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

Definition at line 203 of file Memcache.php.

References PHPExcel_CachedObjectStorage_CacheBase\_getUniqueID().

{
$memcacheServer = (isset($arguments['memcacheServer'])) ? $arguments['memcacheServer'] : 'localhost';
$memcachePort = (isset($arguments['memcachePort'])) ? $arguments['memcachePort'] : 11211;
$cacheTime = (isset($arguments['cacheTime'])) ? $arguments['cacheTime'] : 600;
if (is_null($this->_cachePrefix)) {
$baseUnique = $this->_getUniqueID();
$this->_cachePrefix = substr(md5($baseUnique),0,8).'.';
// Set a new Memcache object and connect to the Memcache server
$this->_memcache = new Memcache();
if (!$this->_memcache->addServer($memcacheServer, $memcachePort, false, 50, 5, 5, true, array($this, 'failureCallback'))) {
throw new Exception('Could not connect to MemCache server at '.$memcacheServer.':'.$memcachePort);
}
$this->_cacheTime = $cacheTime;
}
} // function __construct()

+ Here is the call graph for this function:

PHPExcel_CachedObjectStorage_Memcache::__destruct ( )

Definition at line 229 of file Memcache.php.

References PHPExcel_CachedObjectStorage_CacheBase\getCellList().

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

{
$cacheList = $this->getCellList();
foreach($cacheList as $cellID) {
$this->_memcache->delete($this->_cachePrefix.$cellID.'.cache');
}
} // function __destruct()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Function Documentation

PHPExcel_CachedObjectStorage_Memcache::_storeData ( )
private

Definition at line 45 of file Memcache.php.

References __destruct().

Referenced by addCacheData(), and getCacheData().

{
$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 Exception('Failed to store cell '.$cellID.' in MemCache');
}
}
$this->_currentObjectID = $this->_currentObject = null;
} // function _storeData()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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
void
Exceptions
Exception

Implements PHPExcel_CachedObjectStorage_ICache.

Definition at line 67 of file Memcache.php.

References _storeData().

{
if (($pCoord !== $this->_currentObjectID) && ($this->_currentObjectID !== null)) {
$this->_storeData();
}
$this->_cellCache[$pCoord] = true;
$this->_currentObjectID = $pCoord;
$this->_currentObject = $cell;
return $cell;
} // function addCacheData()

+ Here is the call graph for this function:

PHPExcel_CachedObjectStorage_Memcache::copyCellCollection ( PHPExcel_Worksheet  $parent)

Clone the cell collection.

Returns
void

Reimplemented from PHPExcel_CachedObjectStorage_CacheBase.

Definition at line 163 of file Memcache.php.

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

{
// Get a new id for the new file name
$baseUnique = $this->_getUniqueID();
$newCachePrefix = substr(md5($baseUnique),0,8).'.';
$cacheList = $this->getCellList();
foreach($cacheList as $cellID) {
if ($cellID != $this->_currentObjectID) {
$obj = $this->_memcache->get($this->_cachePrefix.$cellID.'.cache');
if ($obj === false) {
// Entry no longer exists in Memcache, so clear it from the cache array
throw new Exception('Cell entry '.$cellID.' no longer exists in MemCache');
}
if (!$this->_memcache->add($newCachePrefix.$cellID.'.cache',$obj,NULL,$this->_cacheTime)) {
$this->__destruct();
throw new Exception('Failed to store cell '.$cellID.' in MemCache');
}
}
}
$this->_cachePrefix = $newCachePrefix;
} // function copyCellCollection()

+ Here is the call graph for this function:

PHPExcel_CachedObjectStorage_Memcache::deleteCacheData (   $pCoord)

Delete a cell in cache identified by coordinate address.

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

Reimplemented from PHPExcel_CachedObjectStorage_CacheBase.

Definition at line 149 of file Memcache.php.

Referenced by copyCellCollection(), getCacheData(), and isDataSet().

{
// Delete the entry from Memcache
$this->_memcache->delete($this->_cachePrefix.$pCoord.'.cache');
// Delete the entry from our cell address array
} // function deleteCacheData()

+ Here is the caller graph for this function:

PHPExcel_CachedObjectStorage_Memcache::failureCallback (   $host,
  $port 
)

Definition at line 224 of file Memcache.php.

{
throw new Exception('memcache '.$host.':'.$port.' failed');
}
PHPExcel_CachedObjectStorage_Memcache::getCacheData (   $pCoord)

Get cell at a specific coordinate.

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

Implements PHPExcel_CachedObjectStorage_ICache.

Definition at line 113 of file Memcache.php.

References PHPExcel_CachedObjectStorage_CacheBase\$_currentObject, _storeData(), and deleteCacheData().

{
if ($pCoord === $this->_currentObjectID) {
}
$this->_storeData();
// Check if the entry that has been requested actually exists
if (parent::isDataSet($pCoord)) {
$obj = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');
if ($obj === false) {
// Entry no longer exists in Memcache, so clear it from the cache array
throw new Exception('Cell entry '.$cellID.' no longer exists in MemCache');
}
} else {
// Return null if requested entry doesn't exist in cache
return null;
}
// Set current entry to the requested entry
$this->_currentObjectID = $pCoord;
$this->_currentObject = unserialize($obj);
// Re-attach the parent worksheet
$this->_currentObject->attach($this->_parent);
// Return requested entry
} // function getCacheData()

+ Here is the call graph for this function:

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
void
boolean

Reimplemented from PHPExcel_CachedObjectStorage_CacheBase.

Definition at line 87 of file Memcache.php.

References deleteCacheData().

{
// Check if the requested entry is the current object, or exists in the cache
if (parent::isDataSet($pCoord)) {
if ($this->_currentObjectID == $pCoord) {
return true;
}
// Check if the requested entry still exists in Memcache
$success = $this->_memcache->get($this->_cachePrefix.$pCoord.'.cache');
if ($success === false) {
// Entry no longer exists in Memcache, so clear it from the cache array
throw new Exception('Cell entry '.$cellID.' no longer exists in MemCache');
}
return true;
}
return false;
} // function isDataSet()

+ Here is the call graph for this function:

PHPExcel_CachedObjectStorage_Memcache::unsetWorksheetCells ( )

Definition at line 187 of file Memcache.php.

References __destruct().

{
if(!is_null($this->_currentObject)) {
$this->_currentObject->detach();
$this->_currentObject = $this->_currentObjectID = null;
}
// Flush the Memcache cache
$this->__destruct();
$this->_cellCache = array();
// detach ourself from the worksheet, so that it can then delete this object successfully
$this->_parent = null;
} // function unsetWorksheetCells()

+ Here is the call graph for this function:

Field Documentation

PHPExcel_CachedObjectStorage_Memcache::$_cachePrefix = null
private

Definition at line 38 of file Memcache.php.

PHPExcel_CachedObjectStorage_Memcache::$_cacheTime = 600
private

Definition at line 40 of file Memcache.php.

PHPExcel_CachedObjectStorage_Memcache::$_memcache = null
private

Definition at line 42 of file Memcache.php.


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