Skip to content

Commit

Permalink
Cluster refinements:
Browse files Browse the repository at this point in the history
- eZDBFileHandler::$metaData is now a magic property that automatically loads metadata, just as in eZDFS
  • Loading branch information
Bertrand Dunogier committed Aug 30, 2010
1 parent 6208f15 commit ecb22c1
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions kernel/classes/clusterfilehandlers/ezdbfilehandler.php
Expand Up @@ -52,7 +52,7 @@ class eZDBFileHandler
*
* $filePath File path. If specified, file metadata is fetched in the constructor.
*/
function eZDBFileHandler( $filePath = false )
function __construct( $filePath = false )
{
$filePath = eZDBFileHandler::cleanPath( $filePath );
eZDebugSetting::writeDebug( 'kernel-clustering', "db::ctor( '$filePath' )" );
Expand Down Expand Up @@ -82,12 +82,10 @@ function eZDBFileHandler( $filePath = false )
$this->nonExistantStaleCacheHandling = $GLOBALS['eZDBFileHandler_Settings']['NonExistantStaleCacheHandling'];
}

/*!
\public
Load file meta information.
\param $force File stats will be refreshed if true
*/
/**
* Load file meta information from the database
* @param bool $force File stats will be refreshed if true
*/
function loadMetaData( $force = false )
{
// Fetch metadata.
Expand All @@ -96,7 +94,7 @@ function loadMetaData( $force = false )

// we don't fetch metaData if self::metaData === false, since this means
// we already tried and got no results, unless $force == true
if ( ( $this->metaData === false ) && ( $force !== true ) )
if ( ( $this->_metaData === false ) && ( $force !== true ) )
return;

if ( $force && isset( $GLOBALS['eZClusterInfo'][$this->filePath] ) )
Expand All @@ -108,15 +106,15 @@ function loadMetaData( $force = false )
if ( isset( $GLOBALS['eZClusterInfo'][$this->filePath] ) )
{
$GLOBALS['eZClusterInfo'][$this->filePath]['cnt'] += 1;
$this->metaData = $GLOBALS['eZClusterInfo'][$this->filePath]['data'];
$this->_metaData = $GLOBALS['eZClusterInfo'][$this->filePath]['data'];
return;
}

$metaData = $this->backend->_fetchMetadata( $this->filePath );
if ( $metaData )
$this->metaData = $metaData;
$this->_metaData = $metaData;
else
$this->metaData = false;
$this->_metaData = false;

// Clean up old entries if the maximum count is reached
if ( isset( $GLOBALS['eZClusterInfo'] ) &&
Expand All @@ -132,11 +130,14 @@ function loadMetaData( $force = false )
}

/**
* \public
* \static
* \param $filePath Path to the file being stored.
* \param $scope Means something like "file category". May be used to clean caches of a certain type.
* \param $delete true if the file should be deleted after storing.
* Stores a local file to the cluster
*
* @param string $filePath Path to the file being stored.
* @param string $scope File scope. Used to group similar files together. Examples: image, template-block...
* @param string $delete true if the file should be deleted after storing.
* @param string $datatype File mime type
*
* @return void
*/
function fileStore( $filePath, $scope = false, $delete = false, $datatype = false )
{
Expand Down Expand Up @@ -1298,6 +1299,15 @@ function __get( $propertyName )
$cacheType = $this->_cacheType();
return $cacheType;
} break;

case 'metaData':
{
if ( $this->_metaData === null )
{
$this->loadMetaData();
}
return $this->_metaData;
}
}
}

Expand Down Expand Up @@ -1375,7 +1385,7 @@ public function fetchExpiredBinaryItems( $limit = array( 0, 100 ) )
* - then we add a reinitMetaData() method that resets the property to null
* by erasing the cache
**/
public $metaData = null;
public $_metaData = null;

/**
* Indicates that the current cache item is being generated and an old version
Expand Down

0 comments on commit ecb22c1

Please sign in to comment.