Q.Cache Class
A Q.Cache object stores items in a cache and throws out least-recently-used ones.
Constructor
Q.Cache
-
options
Parameters:
-
options
Objectyou can pass the following options:
-
[localStorage]
Boolean optionaluse local storage instead of page storage
-
[sessionStorage]
Boolean optionaluse session storage instead of page storage
-
[name]
String optionalthe name of the cache, not really used for now
-
[max=100]
Integer optionalthe maximum number of items the cache should hold. Defaults to 100.
-
[after]
Q.Cache optionalpass an existing cache with max > this cache's max, to look in first
-
Item Index
Methods
clear
()
static
Accesses the cache and clears all entries from it
each
-
args
-
callback
Cycles through all the entries in the cache
earliest
()
String
Returns the key corresponding to the entry that was touched the earliest
Returns:
get
-
key
-
options
Accesses the cache and gets an entry from it
Parameters:
Returns:
whatever is stored there, or else returns undefined
key
-
args
-
functions
Generates the key under which things will be stored in a cache
Parameters:
Returns:
remove
-
key
Accesses the cache and removes an entry from it.
Parameters:
-
key
Stringthe key of the entry to remove
Returns:
whether there was an existing entry under that key
removeEach
-
args
Removes all the entries in the cache matching the args
Parameters:
-
args
ArrayAn array consisting of some or all the arguments that form the key
set
-
key
-
cbpos
-
subject
-
params
-
options
Accesses the cache and sets an entry in it
Parameters:
-
key
Stringthe key to save the entry under, or an array of arguments
-
cbpos
Numberthe position of the callback
-
subject
ObjectThe "this" object for the callback
-
params
ArrayThe parameters for the callback
-
options
Objectsupports the following options:
-
[dontTouch=false]
Boolean optionalif true, then doesn't mark item as most recently used
-
Returns:
whether there was an existing entry under that key