There are a variety of Least Frequently Used replacement policies used. A strict LFU policy
keeps a request count over all time, and replaces the entries with the lowest count. Using
that policy, the cache becomes polluted with items that were accessed frequently a long time
ago but haven't been accessed recently.
An LFU-Aging cache periodically removes counted requests that are too old. This still requires
some careful tuning because you have to decide how old "too old" is in your application.
This cache builds on LFU-Aging by weighting each access request in favor keeping entries with
recent requests. The defaults for this cache dictate that requests that are older than 60
seconds are discarded, and when more than 5 requests have been recorded in the last 60 seconds,
only the most recent 5 are used in the cache expiration evaluation. 3 requests recorded 5
seconds ago are worth much more than 3 requests recorded 58 seconds ago.
cacheStats:CacheStats [read-only]
Implementation
public function get cacheStats():CacheStats
protected var _cacheValues:Map
protected var _evaluator:CacheObjectEvaluator
protected var _frequencyCount:int
protected var _frequencyThreshold:int
protected var _lastEvaluationTotal:int
protected var _maxValue:int
protected var _missSource:DataSource
protected var _stats:CacheStats
protected var _timer:Timer
public function LFUWeightedAgeCache(cacheMissSource:DataSource, maxValue:int = 1000, evaluator:CacheObjectEvaluator = null, evaluationTime:int = 1000, frequencyThreshold:int = 60000, frequencyCount:int = 5)
Parameters
| cacheMissSource:DataSource — When the data is not found in the cache, it will be requested from
this DataSource.
|
| |
| maxValue:int (default = 1000) — This maximum value of the objects in the cache. If this value is exceeded,
the least frequently used entries are purged.
|
| |
| evaluator:CacheObjectEvaluator (default = null) — If no evaluator is provided, an ObjectCountEvaluator will be used, causing
this cache to store maxValue objects before it starts to purge unused
entries.
|
| |
| evaluationTime:int (default = 1000) — The minimum amount of time that must pass between cache evaluations in
milliseconds.
|
| |
| frequencyThreshold:int (default = 60000) — Any accesses older than this amount will not be considered in the
frequency calculation.
|
| |
| frequencyCount:int (default = 5) — Only the last frequencyCount accesses will be considered for the
frequency calculation.
|
protected function evaluateCache(... ignored):voidParameters
public function getObject(name:String):ObjectParameters
Returns