Class Cache

Cached values, like tables, to minimize process load.

Metamethods

Cache:__index (key) Lookup of missing class members
Cache:__call (key, func, ...) Call on instance.

Methods

Cache:create (...) Create a new instance.
Cache:_init (opts) Initialize a new instance.
Cache:depth () The depth of the internal structure.
Cache:isConsistent () Consistence check.
Cache:isEmpty () Is the internal structure empty.
Cache:isMax () Is the internal structure above the maximum number.
Cache:insert (key, ...) Cache a given entry.
Cache:remove (key) Remove a given entry.
Cache:isValid (key) Is the cached entry still considered valid.
Cache:exists (key) Does the cached entry exist.
Cache:touch (key) Touch the entry.
Cache:get (key) Retrieve an entry.


Metamethods

Cache:__index (key)
Lookup of missing class members

Parameters:

  • key string used for lookup of member

Returns:

    any
Cache:__call (key, func, ...)
Call on instance. This is an alternative interface for maintaining the cached value.

Parameters:

  • key string used for lookup of cached value
  • func callback used for construction of value
  • ... varargs passed to the callback

Returns:

    cached value or a value generated by the callback

Methods

Cache:create (...)
Create a new instance.

Parameters:

  • ... varargs, typically a single table, for options (optional)

Returns:

    self
Cache:_init (opts)
Initialize a new instance.

Parameters:

  • opts table for options (optional)

Returns:

    self
Cache:depth ()
The depth of the internal structure. This value reflects the depth of the "order" structure.

Returns:

    number saying how deep the internal structure is
Cache:isConsistent ()
Consistence check. Verify the internal structure.

Returns:

    boolean for consistency
Cache:isEmpty ()
Is the internal structure empty. This value reflects the depth of the "order" structure.

Returns:

    boolean saying whether the "order" is empty
Cache:isMax ()
Is the internal structure above the maximum number.

Returns:

    boolean saying whether the limit is reached
Cache:insert (key, ...)
Cache a given entry. This can also be false, in case it doesn't exist.

Parameters:

  • key string for lookup
  • ... varargs to be stored

Returns:

    self or value – timestamp pair
Cache:remove (key)
Remove a given entry.

Parameters:

  • key string for lookup

Returns:

    self or found entry, should be same as key
Cache:isValid (key)
Is the cached entry still considered valid. This checks if the key is for an entry that is still within cache time.

Parameters:

  • key string for lookup

Returns:

    boolean saying whether the limit is reached
Cache:exists (key)
Does the cached entry exist.

Parameters:

  • key string for lookup

Returns:

    boolean saying whether the entry is cached
Cache:touch (key)
Touch the entry. This mark the entry as still in use, moving it up front again.

Parameters:

  • key string for lookup

Returns:

    self or found entry, should be same as key
Cache:get (key)
Retrieve an entry. Will return false in case it's known to not exist and nil in case of a cache miss.

Parameters:

  • key string for lookup

Returns:

    cached values
generated by LDoc 1.4.6 Last updated 2019-02-06 11:27:15