The cache class is an implementation of a generic cache. It stores a fixed number of cache-items discarding the least used ones while keeping the frequently used ones.
Be the first to leve a comment or ask a question about the code!
The interface:
- Add(Key as Variant, Data as Variant, Optional Cost as Double)
As you might expect this function adds a new item to the cache. The cost is a double value used to give items in the cache different value. Items with a high cost are keept over items with a low cost. The neutral cost is 1.
- Exists(Key as Variant) as Bool
The exists function serves two functions. The first is to determine if an object is located in the cache. The second is to locate it.
- GetItem() as Variant
The functions retrives the last item located by using Exists().
- CacheHits() as Long
Returns the number of times Exists() has found the item in the cache.
- CacheMisses() as Long
Returns the number of times Exists() didn't find the item in the cache.
- CacheSuccessRatio() as Double
Returns the ratio between hits and misses.
- ResetStatistics()
Resets the statistics.
- Capacity as Long
Gets and Sets the number of items to be stored in the cache.