Class MOXMAN_Util_LfuCache
Inheritance | MOXMAN_Util_LfuCache |
---|
This class provides a key based Least-Frequently Used cache algoritm.
It will keep track of the most used cached items and when the cache is full it will remove the less used items.
Public Methods
Method | Description | Defined By |
---|---|---|
__construct() | Constructs a new instance with a specified size. | MOXMAN_Util_LfuCache |
__toString() | Converts the item into a string value. | MOXMAN_Util_LfuCache |
clear() | Remove all cached items. | MOXMAN_Util_LfuCache |
get() | Returns a cached item by key or null if it doesn't exist. | MOXMAN_Util_LfuCache |
has() | Returns true/false if the item by key is in cache or not. | MOXMAN_Util_LfuCache |
put() | Puts the specified object reference into the cache. | MOXMAN_Util_LfuCache |
remove() | Removes an item by key. | MOXMAN_Util_LfuCache |
Method Details
Constructs a new instance with a specified size.
public void __construct ( $config = [] ) | ||
$config | array | Otional array with config items for the lfu cache. |
Converts the item into a string value.
public String __toString ( ) | ||
return | String | Value with the items currently in cache. |
---|
Remove all cached items.
public void clear ( ) |
Returns a cached item by key or null if it doesn't exist.
public Object get ( $key ) | ||
$key | string | Key to get object by from cache. |
return | Object | Cached item or null if it wasn't found. |
---|
Returns true/false if the item by key is in cache or not.
public Boolean has ( $key ) | ||
$key | string | Key to check for in cache. |
return | Boolean | True if the item exists in cache. |
---|
Puts the specified object reference into the cache.
public &Object put ( $key, <b>&</b>$obj ) | ||
$key | string | Name to put the cache item at. |
$obj | Object | Object to put in cache. |
return | Object | Object reference to the item that got put in cache. |
---|
Removes an item by key.
public &MOXMAN_Util_LfuCache remove ( $key ) | ||
$key | string | Key to remove. |
return | MOXMAN_Util_LfuCache | Cache instance. |
---|