User Tools

Site Tools


sib:cache

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
sib:cache [2019/08/28 09:19]
hubbe [Custom configuration]
sib:cache [2019/08/28 09:24] (current)
hubbe
Line 78: Line 78:
   * ttl: Number of seconds that the data will live in the cache   * ttl: Number of seconds that the data will live in the cache
   * ttlcheckinterval:​ Number of seconds between the checkTTL executions, ie resolution of ttl   * ttlcheckinterval:​ Number of seconds between the checkTTL executions, ie resolution of ttl
 +
 +
 +==== Default behaviour ====
 +
 +When the behaviour of the SIBCache is not overridden by overriding the checkTTL, get, getsize and set methods the default behaviour of the cache is used. Here is a short description of the inner workings of the default cache.
 +
 +The SIBCache.cache object contains the in-memory cache as an object. When setting the cache the SIBCache.cache[msg.cache.key] element is set to a new object on the form:
 +<code javascript>​
 +{data:​msg.cache.data,​ t:​Date.now()}
 +</​code>​
 +
 +This allows the checkTTL method to loop through all elements of the SIBCache.cache object and check the t value against the current time and TTL settings, removing all elements of the SIBCache.cache object that are too old.
 +
 +The setSize method simply checks the number of elements in the SIBCache.chace object and reports that as the cache length.
 +
 +The get method simply checks if the msg.cache.key key exists in the SIBCache.cache object. If so the SIBCache.cache[msg.key].data element is returned in the response message.
sib/cache.txt ยท Last modified: 2019/08/28 09:24 by hubbe