LFSWorldSQLCache Class Reference

List of all members.

Public Member Functions

 LFSWorldSQLCache ($params)
 get ($params)
 save ($data, $params)
 requiresDataReload ()
 purgeOld ($params)
 createKey ()
 getLastUpdate ($params)
 _countRows ($params, $threshold)

Protected Member Functions

 _createPaginationData ($params, $totalRows)
 _stringify ($array)
 _escape ($string)

Protected Attributes

 $m_aDefaults

Detailed Description

Provides a generic SQL cache provider.

Version:
1.0.00

Definition at line 16 of file lfsworldsqlcache.php.


Constructor & Destructor Documentation

LFSWorldSQLCache::LFSWorldSQLCache params  ) 
 

LFSWorldSQLCache Ctor.

Parameters:
params (Array) An array of options to configure the cache.
Returns:
(Void)

Definition at line 42 of file lfsworldsqlcache.php.

References array_merge_replace().


Member Function Documentation

LFSWorldSQLCache::_countRows params,
threshold
 

Gets the total entry count within a specified threshold.

Parameters:
params (Array) Parameters to be used in getting the total rows count.
threshold (Integer) Threshold in seconds.
Returns:
(Integer) Total entry count.

Definition at line 209 of file lfsworldsqlcache.php.

Referenced by get().

LFSWorldSQLCache::_createPaginationData params,
totalRows
[protected]
 

Creates an array of meta data that makes it easier to paginate results.

Parameters:
params (Array)
totalRows (Integer) Total rows available.
Returns:
(Array) Meta data for pagination such as current page, results per page, num of pages etc.

Definition at line 231 of file lfsworldsqlcache.php.

Referenced by get().

LFSWorldSQLCache::_escape string  )  [protected]
 

Escape a astring to be safely included in a query.

Parameters:
string (String) String to be escaped.
Returns:
(String) The escaped string.

Definition at line 275 of file lfsworldsqlcache.php.

Referenced by _stringify().

LFSWorldSQLCache::_stringify array  )  [protected]
 

Takes an array of values, escapes them for SQL insertion and converts them to a string.

Parameters:
array (Array) Array of data to be 'stringified'.
Returns:
(String) String form of escaped data that 'should' be ready for use in an SQL insert/update/replace statement.

Definition at line 262 of file lfsworldsqlcache.php.

References _escape().

Referenced by save().

LFSWorldSQLCache::createKey  ) 
 

Creates a unique key for the data provided.

Parameters:
uniqData (String) A unique string to create a further unique identifier.
Returns:
(String) A unique identifier for the data given.

Definition at line 172 of file lfsworldsqlcache.php.

LFSWorldSQLCache::get params  ) 
 

Retrieve data from the cache.

Parameters:
params (Array) An array of params to be used in querying the cache. (Cache group, entry key etc)
Returns:
(Array) An array including meta data, and retrieved data on success, false on failure.

Definition at line 54 of file lfsworldsqlcache.php.

References _countRows(), _createPaginationData(), and array_merge_replace().

LFSWorldSQLCache::getLastUpdate params  ) 
 

Returns the last update of the last cache fetched.

Parameters:
params (Array) Array of params to use in getting last update. (Cache key, group etc)
Returns:
(Integer) 0 if the update time could not be retrieved, unix timestamp of last update otherwise.

Definition at line 184 of file lfsworldsqlcache.php.

References array_merge_replace().

Referenced by purgeOld().

LFSWorldSQLCache::purgeOld params  ) 
 

Purges entries older than the threshold from the cache. Be warned that setting the purge threshold too low will render the fallback feature of interfaces useless.

Parameters:
params (Array) An array of params to pull the purge query data from.
Returns:
(Void)

Definition at line 158 of file lfsworldsqlcache.php.

References getLastUpdate().

LFSWorldSQLCache::requiresDataReload  ) 
 

Returns a boolean indicating whether LFSWorldFileCache::get should be called immediately after a save.

Returns:
(Boolean) False because the file cache does not require this behaviour.

Definition at line 145 of file lfsworldsqlcache.php.

LFSWorldSQLCache::save data,
params
 

Save data to the cache.

Parameters:
data (Mixed) The data to cache.
params (Array) An array of params to be used in saving the data. (Cache group, entry key etc)
Returns:
(Void)

Definition at line 111 of file lfsworldsqlcache.php.

References _stringify().


Member Data Documentation

LFSWorldSQLCache::$m_aDefaults [protected]
 

Initial value:

 array(   'lifeTime' => 60,
                                'noValidityCheck' => false,
                                'queries' => array( 'count' => 'SELECT COUNT(lastUpdate) AS rowCount FROM {{table}} WHERE lastUpdate >= {{threshold}}',
                                                    'get' => 'SELECT * FROM {{table}} WHERE lastUpdate >= {{threshold}} {{where}} {{limit}} {{order}}',
                                                    'save' => 'REPLACE INTO {{table}} {{fields}} VALUES {{values}}',
                                                    'oldThreshold' => 'SELECT DISTINCT lastUpdate FROM {{table}} ORDER BY lastUpdate DESC LIMIT 1, 1'),
                                'resultsPerPage' => 0,
                                'page' => 1,
                                'getTransformer' => '',
                                'saveTransformer' => '',
                                'where' => '',
                                'order' => '')
(Array) An array of options to use as default configuration values.

Definition at line 22 of file lfsworldsqlcache.php.


Generated on Wed Oct 25 03:13:33 2006 for LFSWorldParsingProviderFramework by  doxygen 1.4.6