Overview

Packages

  • ClipIt
    • clipit
      • api
    • urjc
      • backend
  • Elgg
    • Core
      • Access
      • Authentication
      • Cache
      • Caches
      • Core
      • DataMode
        • Site
      • DataModel
        • Annotations
        • Entities
        • Extender
        • File
        • Importable
        • Loggable
        • Notable
        • Object
        • User
      • DataStorage
      • Exception
      • Exceptions
        • Stub
      • FileStore
        • Disk
      • Groups
      • Helpers
      • HMAC
      • Memcache
      • Metadata
      • Navigation
      • ODD
      • Output
      • Plugins
        • Settings
      • Sessions
      • SocialModel
        • Friendable
        • Locatable
      • WebServicesAPI
      • Widgets
      • XML
      • XMLRPC
    • Exceptions
      • Stub
  • None
  • PHP

Classes

  • ElggCache
  • ElggLRUCache
  • ElggSharedMemoryCache
  • ElggStaticVariableCache
  • ElggVolatileMetadataCache
  • Overview
  • Package
  • Class
  • Tree

Class ElggLRUCache

Least Recently Used Cache

A fixed sized cache that removes the element used last when it reaches its size limit.

Based on https://github.com/cash/LRUCache

ElggLRUCache implements ArrayAccess
Package: Elgg\Core\Cache
Located at ElggLRUCache.php
Methods summary
public
# __construct( integer $size )

Create a LRU Cache

Create a LRU Cache

Parameters

$size
integer
$size The size of the cache

Throws

InvalidArgumentException
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
# clear( )

Clear the cache

Clear the cache

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

ArrayAccess::offsetSet()

Implementation of

ArrayAccess::offsetSet()
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

ArrayAccess::offsetGet()

Implementation of

ArrayAccess::offsetGet()
public
# offsetUnset( integer|string $key )

Unsets a key.

Unsets a key.

Parameters

$key
integer|string
$key The key to unset.

See

ArrayAccess::offsetUnset()

Implementation of

ArrayAccess::offsetUnset()
public boolean
# offsetExists( integer|string $key )

Does key exist?

Does key exist?

Parameters

$key
integer|string
$key A key to check for.

Returns

boolean

See

ArrayAccess::offsetExists()

Implementation of

ArrayAccess::offsetExists()
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

API documentation generated by ApiGen 2.8.0