Class Cache
Cached values, like tables, to minimize process load.
-
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
-
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:
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:
Returns:
boolean saying whether the limit is reached
-
Cache:exists (key)
-
Does the cached entry exist.
Parameters:
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:
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:
Returns:
cached values