Class ElggLRUCache
-
ElggLRUCache
implements
ArrayAccess
Methods summary
public
|
#
__construct( integer $size )
Create a LRU Cache
Parameters
- $size
integer $size The size of the cache
Throws
|
public
mixed
|
#
get( integer|string $key, mixed $default = null )
Get the value cached with this key
Get the value cached with this key
Parameters
- $key
integer|string $key The key. Strings that are ints are cast to ints.
- $default
mixed $default The value to be returned if key not found. (Optional)
Returns
mixed
|
public
|
#
set( integer|string $key, mixed $value )
Add something to the cache
Add something to the cache
Parameters
- $key
integer|string $key The key. Strings that are ints are cast to ints.
- $value
mixed $value The value to cache
|
public
integer
|
#
size( )
Get the number of elements in the cache
Get the number of elements in the cache
Returns
integer
|
public
boolean
|
#
containsKey( integer|string $key )
Does the cache contain an element with this key
Does the cache contain an element with this key
Parameters
- $key
integer|string $key The key
Returns
boolean
|
public
mixed
|
#
remove( integer|string $key )
Remove the element with this key.
Remove the element with this key.
Parameters
- $key
integer|string $key The key
Returns
mixed Value or null if not set
|
public
|
|
protected
|
#
recordAccess( integer|string $key )
Moves the element from current position to end of array
Moves the element from current position to end of array
Parameters
- $key
integer|string $key The key
|
public
|
#
offsetSet( integer|string $key, mixed $value )
Assigns a value for the specified key
Assigns a value for the specified key
Parameters
- $key
integer|string $key The key to assign the value to.
- $value
mixed $value The value to set.
See
Implementation of
|
public
mixed
|
#
offsetGet( integer|string $key )
Get the value for specified key
Get the value for specified key
Parameters
- $key
integer|string $key The key to retrieve.
Returns
mixed
See
Implementation of
|
public
|
#
offsetUnset( integer|string $key )
Unsets a key.
Parameters
- $key
integer|string $key The key to unset.
See
Implementation of
|
public
boolean
|
#
offsetExists( integer|string $key )
Does key exist?
Parameters
- $key
integer|string $key A key to check for.
Returns
boolean
See
Implementation of
|
Properties summary
protected
integer
|
$maximumSize
|
|
|
protected
array
|
$data
|
array() |
#
The front of the array contains the LRU element
The front of the array contains the LRU element
|