Class MOXMAN_Util_LfuCache

InheritanceMOXMAN_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

Hide inherited methods

MethodDescriptionDefined 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

__construct() public method

Constructs a new instance with a specified size.

public void __construct ( $config = [] )
$config array

Otional array with config items for the lfu cache.

__toString() public method

Converts the item into a string value.

public String __toString ( )
return String

Value with the items currently in cache.

clear() public method

Remove all cached items.

public void clear ( )
get() public method

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.

has() public method

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.

put() public method

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.

remove() public method

Removes an item by key.

public &MOXMAN_Util_LfuCache remove ( $key )
$key string

Key to remove.

return MOXMAN_Util_LfuCache

Cache instance.