Zeta Components - high quality PHP components

Zeta Components Manual :: Docs For Class ezcCacheStackLruReplacementStrategy

Cache::ezcCacheStackLruReplacementStrategy

Class ezcCacheStackLruReplacementStrategy

Least recently used replacement strategy.

This replacement strategy will purge items first that have been used least recently. In case the ezcCacheStackableStorage this replacement strategy works on runs full, first all outdated items (which are older than TTL) will be purged. If this does not last to achieve the desired free rate, items will be purged that have not been stored or restored for the longest time, until the free rate is reached.

This class is not intended to be used directly, but should be configured to be used by an ezcCacheStack instance. This can be achieved via ezcCacheStackOptions. The meta data class used by this class is ezcCacheStackLruMetaData.

For more information on LRU see {@see http://en.wikipedia.org/wiki/Cache_algorithms}.

Source for this file: /Cache/src/replacement_strategies/lru.php

ezcCacheStackBaseReplacementStrategy
   |
   --ezcCacheStackLruReplacementStrategy
Version:   //autogentag//

Method Summary

protected static void checkMetaData( $metaData )
Checks if the given meta data is processable.
public static ezcCacheStackLruMetaData createMetaData( )
Returns a fresh meta data instance.
public static array(string) delete( $conf , $metaData , $itemId , [ $itemAttributes = array()] , [ $search = false] )
Deletes the data with the given $itemId from the given $storage.
public static mixed restore( $conf , $metaData , $itemId , [ $itemAttributes = array()] , [ $search = false] )
Restores the data with the given $itemId from the storage configured in $conf.
public static void store( $conf , $metaData , $itemId , $itemData , [ $itemAttributes = array()] )
Stores the given $itemData in the given storage.

Methods

checkMetaData

static void checkMetaData( ezcCacheStackMetaData $metaData )

Checks if the given meta data is processable.

Throws an exception if the given meta data is not processable.

Parameters:
Name Type Description
$metaData ezcCacheStackMetaData
Exceptions:
Type Description
ezcCacheInvalidMetaDataException if the given $metaData is not an instance of ezcCacheStackLruMetaData.

createMetaData

static ezcCacheStackLruMetaData createMetaData( )

Returns a fresh meta data instance.

Returns a freshly created instance of ezcCacheStackLruMetaData.

delete

static array(string) delete( ezcCacheStackStorageConfiguration $conf , ezcCacheStackMetaData $metaData , string $itemId , [array(string=>string) $itemAttributes = array()] , [bool $search = false] )

Deletes the data with the given $itemId from the given $storage.

Deletes the desired item with $itemId and optionally $itemAttributes from the ezcCacheStackableStorage configured in $conf using. The item IDs returned by this call are updated in $metaData, that they are no longer stored in the $storage.

Parameters:
Name Type Description
$conf ezcCacheStackStorageConfiguration
$metaData ezcCacheStackMetaData
$itemId string
$itemAttributes array(string=>string)
$search bool
Exceptions:
Type Description
ezcCacheInvalidMetaDataException if the given $metaData is not an instance of ezcCacheStackLruMetaData.

restore

static mixed restore( ezcCacheStackStorageConfiguration $conf , ezcCacheStackMetaData $metaData , string $itemId , [array(string=>string) $itemAttributes = array()] , [bool $search = false] )

Restores the data with the given $itemId from the storage configured in $conf.

This method restores the item data identified by $itemId and optionally $itemAttributes from the ezcCacheStackableStorage given in $conf using ezcCacheStackableStorage::restore(). The result of this action is returned by the method. This means, the desired item data is returned on success, false is returned if the data is not available.

A successful restore is recorded in $metaData as a "recent usage", with updating the last usage timestamp of $itemId to the current time. A restore failure results in a removal of $itemId.

Parameters:
Name Type Description
$conf ezcCacheStackStorageConfiguration
$metaData ezcCacheStackMetaData
$itemId string
$itemAttributes array(string=>string)
$search bool
Exceptions:
Type Description
ezcCacheInvalidMetaDataException if the given $metaData is not an instance of ezcCacheStackLruMetaData.

store

static void store( ezcCacheStackStorageConfiguration $conf , ezcCacheStackMetaData $metaData , string $itemId , mixed $itemData , [array(string=>string) $itemAttributes = array()] )

Stores the given $itemData in the given storage.

This method stores the given $itemData under the given $itemId and assigns the given $itemAttributes to it in the ezcCacheStackableStorage configured in $conf. The storing results in an update of $metaData, reflecting that the item with $itemId was recently used.

In case the number of items in the storage exceeds $conf->itemLimit, items will be deleted from the storage. First all outdated items will be removed using ezcCacheStackableStorage::purge(). If this does not free the desired $conf->freeRate fraction of $conf->itemLimit, those items that have been used least recently will be deleted. The changes of freeing items are recorded in $metaData.

Parameters:
Name Type Description
$conf ezcCacheStackStorageConfiguration
$metaData ezcCacheStackMetaData
$itemId string
$itemData mixed
$itemAttributes array(string=>string)
Exceptions:
Type Description
ezcCacheInvalidMetaDataException if the given $metaData is not an instance of ezcCacheStackLruMetaData.
Documentation generated by phpDocumentor 1.4.3