Queue
Queuing is an optimization mechanism for fast display to the browser.
queue
unqueue
isQueued
commit
queue(entity, strong)
queue(entity, strong)
Adds an item or an array of items to the queue. This is a fast operation to bypass deep item analysis. It does not provide object uniqueness. The queue functions as a regular data store. If an item exists in the cache it is not replaced or added to the queue. Set the second strong
parameter to true and force replacement in the cache.
One
get()
calls return queued items that are not yet cached as if they were already cached. Their content however is not yet enforced as unique.
Parameters
entityOrArray
Object | Array<Object>
, object or array of objects to add to the queuestrong
Boolean
, whether to replace existing items into the cache. Defaults to false (same as a weak put). Set to true to force replacement of existing cache items that are being queued.
Returns
number
count of items that were queued.
Example:
Items existing in the cache are not replaced
Cache prevails
Queue an item strongly. It might exist both on cache and queue. In such case get()
favors the cached item for retrieval.
unqueue(entity)
unqueue(entity)
Removes a single uid entity from the queue if queued.
Parameters
entity
Object
The entity to be unqueued
Returns
true
on success orfalse
otherwise
Example
getQueued(uidOrEntity)
getQueued(uidOrEntity)
Retrieves a specific entity if queued in the cache.
Parameters
uidOrEntity
string | Object
object (or its unique id) to be retrieved from queue
Returns
the queued entity if existing or
undefined
otherwise
Example
commit(threadId, strong)
commit(threadId, strong)
Commits the queued items to a specific thread. By default commits are weak. If an item being commited already exists in the cache it is not replaced. Set the second parameter to true to force strong commits where all queued items are pushed into the cache.
Parameters
threadId
string
the id of the thread to commit all items into. Defaults tomain
. Note that all items are always placed on the main thread even if another thread id is supplied. In such case items end up on the main thread AND the thread with the id passed in. Of course there is a single instance of the item in the cache. Item is only referenced on each thread.strong
boolean
by default commits are weak. Set this to true to force all queued items to be replaced in the cache.
Returns
history state
Object
Example
Last updated