<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to cache</title><link>https://sourceforge.net/p/nsdci/wiki/cache/</link><description>Recent changes to cache</description><atom:link href="https://sourceforge.net/p/nsdci/wiki/cache/feed" rel="self"/><language>en</language><lastBuildDate>Wed, 01 Apr 2015 22:46:56 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/nsdci/wiki/cache/feed" rel="self" type="application/rss+xml"/><item><title>cache modified by Anonymous</title><link>https://sourceforge.net/p/nsdci/wiki/cache/</link><description>&lt;div class="markdown_content"&gt;&lt;h1 id="cache-api-cache"&gt;Cache API (cache)&lt;/h1&gt;
&lt;p&gt;nsdci/dcicommon/cache.c &lt;/p&gt;
&lt;h2 id="introduction"&gt;Introduction&lt;/h2&gt;
&lt;p&gt;The Cache API provides a mechanism to create size-based and time-based named caches. The Network Cache Flush API (&lt;a class="" href="../ncf"&gt;ncf&lt;/a&gt;) is used to send cache flush messages. Together they provide a powerful, high performance cache-messaging service. The Cache API functions at a very low level and great care should be taken in its use. See the "Best Practices" section for examples of how to effectively use the Cache API. &lt;/p&gt;
&lt;h2 id="tcl-api"&gt;TCL API&lt;/h2&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="o"&gt;--------------------------------------------------------------------------------&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id="cachecreateentry"&gt;cache.createEntry&lt;/h3&gt;
&lt;p&gt;Creates an entry handle in &lt;em&gt;cacheName&lt;/em&gt; identified by &lt;em&gt;key&lt;/em&gt;. &lt;em&gt;newVariable&lt;/em&gt; is updated with 1 if an entry for the given key already exists. A handle to the entry is returned. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;cache.createEntry&lt;/strong&gt; &lt;em&gt;cacheName key newVariable&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Argument&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;Description&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;cacheName&lt;/em&gt;&lt;br /&gt;
String. The name of the cache bucket. &lt;/p&gt;
&lt;p&gt;&lt;em&gt;key&lt;/em&gt;&lt;br /&gt;
String. The key name to be used. &lt;/p&gt;
&lt;p&gt;&lt;em&gt;newVariable&lt;/em&gt;&lt;br /&gt;
String. Variable name to use for the new entry indicator. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Return&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt; Description&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;String&lt;/code&gt;&lt;br /&gt;
Success. The handle of the entry. &lt;/p&gt;
&lt;p&gt;&lt;code&gt;newVariable&lt;/code&gt;&lt;br /&gt;
Boolean. 1 if an entry for the given key already exists, 0 if not. &lt;/p&gt;
&lt;p&gt;&lt;code&gt;TCL_ERROR&lt;/code&gt;&lt;br /&gt;
Failure. An error occurred. See the server log for more information. &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="o"&gt;--------------------------------------------------------------------------------&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id="cachecreatesized"&gt;cache.createSized&lt;/h3&gt;
&lt;p&gt;Creates a named cache, pruned by size. &lt;strong&gt;NOTE:&lt;/strong&gt; The Cache API allows the creation of multiple caches of the same name, essentially overwriting the previous cache causing a memory leak. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;cache.createSized&lt;/strong&gt; &lt;em&gt;cacheName size&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Argument&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;Description&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;cacheName&lt;/em&gt;&lt;br /&gt;
String. The name of the cache bucket. &lt;/p&gt;
&lt;p&gt;&lt;em&gt;size&lt;/em&gt;&lt;br /&gt;
Numeric. The size of the bucket in bytes. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Return&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt; Description&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;NULL&lt;/code&gt;&lt;br /&gt;
Success. The cache bucket was created. &lt;/p&gt;
&lt;p&gt;&lt;code&gt;TCL_ERROR&lt;/code&gt;&lt;br /&gt;
Failure. An error occurred. See the server log for more information. &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="o"&gt;--------------------------------------------------------------------------------&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id="cachecreatetimed"&gt;cache.createTimed&lt;/h3&gt;
&lt;p&gt;Creates a named cache, pruned by time. &lt;strong&gt;NOTE:&lt;/strong&gt; The Cache API allows the creation of multiple caches of the same name, essentially overwriting the previous cache causing a memory leak. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;cache.createSized&lt;/strong&gt; &lt;em&gt;cacheName timeout&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Argument&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;Description&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;cacheName&lt;/em&gt;&lt;br /&gt;
String. The name of the cache bucket. &lt;/p&gt;
&lt;p&gt;&lt;em&gt;timeout&lt;/em&gt;&lt;br /&gt;
Integer. The TTL in minutes. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Return&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt; Description&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;NULL&lt;/code&gt;&lt;br /&gt;
Success. The cache bucket was created. &lt;/p&gt;
&lt;p&gt;&lt;code&gt;TCL_ERROR&lt;/code&gt;&lt;br /&gt;
Failure. An error occurred. See the server log for more information. &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="o"&gt;--------------------------------------------------------------------------------&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id="cachedeleteentry"&gt;cache.deleteEntry&lt;/h3&gt;
&lt;p&gt;Removes an entry from the named cache. &lt;strong&gt;NOTE:&lt;/strong&gt; This command does not free the memory associated with the cache entry's value. To delete an entry and free its current value, you must call &lt;em&gt;cache.flushEntry&lt;/em&gt;. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;cache.deleteEntry&lt;/strong&gt; &lt;em&gt;entry&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Argument&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;Description&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;entry&lt;/em&gt;&lt;br /&gt;
String. The handle returned by &lt;em&gt;cache.createEntry&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Return&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt; Description&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;NULL&lt;/code&gt;&lt;br /&gt;
Success. The entry was removed from the named cache. &lt;/p&gt;
&lt;p&gt;&lt;code&gt;TCL_ERROR&lt;/code&gt;&lt;br /&gt;
Failure. An error occurred. See the server log for more information. &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="o"&gt;--------------------------------------------------------------------------------&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id="cachefindentry"&gt;cache.findEntry&lt;/h3&gt;
&lt;p&gt;Finds a cache entry identified by &lt;em&gt;key&lt;/em&gt; in &lt;em&gt;cacheName&lt;/em&gt;. A handle to this entry is returned. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;cache.findEntry&lt;/strong&gt; &lt;em&gt;cacheName key&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Argument&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;Description&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;cacheName&lt;/em&gt;&lt;br /&gt;
String. The name of the cache. &lt;/p&gt;
&lt;p&gt;&lt;em&gt;key&lt;/em&gt;&lt;br /&gt;
String. The identifing key in the named cache. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Return&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt; Description&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;String&lt;/code&gt;&lt;br /&gt;
Success. The handle of the cache entry.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;TCL_ERROR&lt;/code&gt;&lt;br /&gt;
Failure. An error occurred. See the server log for more information. &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="o"&gt;--------------------------------------------------------------------------------&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id="cacheflushentry"&gt;cache.flushEntry&lt;/h3&gt;
&lt;p&gt;Deletes an entry from the named cache after first unsetting the current value (if any). &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;cache.flushEntry&lt;/strong&gt; &lt;em&gt;entry&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Argument&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;Description&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;entry&lt;/em&gt;&lt;br /&gt;
String. The handle to the value returned by &lt;em&gt;cache.findEntry&lt;/em&gt;. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Return&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt; Description&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;NULL&lt;/code&gt;&lt;br /&gt;
Success. The value was unset, the memory released, and the entry removed. &lt;/p&gt;
&lt;p&gt;&lt;code&gt;TCL_ERROR&lt;/code&gt;&lt;br /&gt;
Failure. An error occurred. See the server log for more information. &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="o"&gt;--------------------------------------------------------------------------------&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id="cachegetvalue"&gt;cache.getValue&lt;/h3&gt;
&lt;p&gt;Retrieves the string value of an entry handle returned by &lt;em&gt;cache.findEntry&lt;/em&gt; The dataVariable argument is then updated with the value if the value is not NULL. If the value is not NULL a "1" is returned, else "0". &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;cache.getValue&lt;/strong&gt; &lt;em&gt;entry dataVariable&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Argument&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;Description&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;entry&lt;/em&gt;&lt;br /&gt;
String. The handle to the value returned by &lt;em&gt;cache.findEntry&lt;/em&gt;. &lt;/p&gt;
&lt;p&gt;&lt;em&gt;dataVariable &lt;/em&gt;&lt;br /&gt;
String. The name of the variable to set the result in. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Return&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt; Description&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;boolean&lt;/code&gt;&lt;br /&gt;
Success. 1 the value was found and &lt;em&gt;dataVariable&lt;/em&gt; was set. &lt;/p&gt;
&lt;p&gt;&lt;code&gt;dataVariable&lt;/code&gt;&lt;br /&gt;
String. This variable is self initializing and only set if the value is not NULL. &lt;/p&gt;
&lt;p&gt;&lt;code&gt;TCL_ERROR&lt;/code&gt;&lt;br /&gt;
Failure. An error occurred. See the server log for more information. &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="o"&gt;--------------------------------------------------------------------------------&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id="cachelock"&gt;cache.lock&lt;/h3&gt;
&lt;p&gt;Locks the named cache. The lock is an exclusion lock (mutex). &lt;strong&gt;Note:&lt;/strong&gt; See "Best Practices" for proper implementation. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;cache.lock&lt;/strong&gt; &lt;em&gt;cacheName&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Argument&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;Description&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;cacheName&lt;/em&gt;&lt;br /&gt;
String. The name of the cache. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Return&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt; Description&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;NULL&lt;/code&gt;&lt;br /&gt;
Success. The cache has been locked. &lt;/p&gt;
&lt;p&gt;&lt;code&gt;TCL_ERROR&lt;/code&gt;&lt;br /&gt;
Failure. An error occurred. See the server log for more information. &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="o"&gt;--------------------------------------------------------------------------------&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id="cachesetvalue"&gt;cache.setValue&lt;/h3&gt;
&lt;p&gt;Updates the cache entry's value, freeing any existing value. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;cache.setValue&lt;/strong&gt; &lt;em&gt;entry value&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Argument&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;Description&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;entry&lt;/em&gt;&lt;br /&gt;
String. The handle returned by &lt;em&gt;cache.createEntry&lt;/em&gt; or &lt;em&gt;cache.findEntry&lt;/em&gt;. &lt;/p&gt;
&lt;p&gt;&lt;em&gt;value&lt;/em&gt;&lt;br /&gt;
String. The value to set. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Return&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt; Description&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;NULL&lt;/code&gt;&lt;br /&gt;
Success. The value was set. &lt;/p&gt;
&lt;p&gt;&lt;code&gt;TCL_ERROR&lt;/code&gt;&lt;br /&gt;
Failure. An error occurred. See the server log for more information. &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="o"&gt;--------------------------------------------------------------------------------&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id="cacheunlock"&gt;cache.unlock&lt;/h3&gt;
&lt;p&gt;Unlocks the named cache. &lt;strong&gt;Note:&lt;/strong&gt; See "Best Practices" for proper implementation. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;cache.unlock&lt;/strong&gt; &lt;em&gt;cacheName&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Argument&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;Description&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;cacheName&lt;/em&gt;&lt;br /&gt;
String. The name of the cache. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Return&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt; Description&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;NULL&lt;/code&gt;&lt;br /&gt;
Success. The cache has been unlocked. &lt;/p&gt;
&lt;p&gt;&lt;code&gt;TCL_ERROR&lt;/code&gt;&lt;br /&gt;
Failure. An error occurred. See the server log for more information. &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="o"&gt;--------------------------------------------------------------------------------&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id="cacheunsetvalue"&gt;cache.unsetValue&lt;/h3&gt;
&lt;p&gt;Unsets the string value of a given cache entry, freeing the data and resetting the value to NULL. This does not delete the entry itself. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Argument&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt;Description&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;entry&lt;/em&gt;&lt;br /&gt;
String. The handle returned by &lt;em&gt;cache.createEntry&lt;/em&gt; or &lt;em&gt;cache.findEntry&lt;/em&gt;. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Return&lt;/strong&gt;&lt;br /&gt;
&lt;strong&gt; Description&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;NULL&lt;/code&gt;&lt;br /&gt;
Success. The value was unset. &lt;/p&gt;
&lt;p&gt;&lt;code&gt;TCL_ERROR&lt;/code&gt;&lt;br /&gt;
Failure. An error occurred. See the server log for more information. &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="o"&gt;--------------------------------------------------------------------------------&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;cache.wait cache.timedWait cache.broadcast cache.signal &lt;/p&gt;
&lt;h2 id="usage"&gt;Usage&lt;/h2&gt;
&lt;p&gt;The following &lt;a class="" href="http://code.google.com/p/aolserver/wiki/nscp" rel="nofollow"&gt;Control Port&lt;/a&gt; session is meant to give an overview only. Please see the "Best Practices" section on how to safely use the Cache API. &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;    &lt;span class="nl"&gt;frontend:&lt;/span&gt;&lt;span class="n"&gt;nscp&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;createSized&lt;/span&gt; &lt;span class="n"&gt;myCache&lt;/span&gt; &lt;span class="mi"&gt;5000000&lt;/span&gt;

    &lt;span class="nl"&gt;frontend:&lt;/span&gt;&lt;span class="n"&gt;nscp&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;lock&lt;/span&gt; &lt;span class="n"&gt;myCache&lt;/span&gt;

    &lt;span class="nl"&gt;frontend:&lt;/span&gt;&lt;span class="n"&gt;nscp&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;createEntry&lt;/span&gt; &lt;span class="n"&gt;myCache&lt;/span&gt; &lt;span class="n"&gt;foo&lt;/span&gt; &lt;span class="n"&gt;existsBoolean&lt;/span&gt;
    &lt;span class="n"&gt;eid0x619088&lt;/span&gt;
    &lt;span class="nl"&gt;frontend:&lt;/span&gt;&lt;span class="n"&gt;nscp&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;setValue&lt;/span&gt; &lt;span class="n"&gt;eid0x619088&lt;/span&gt; &lt;span class="s"&gt;"my value"&lt;/span&gt;

    &lt;span class="nl"&gt;frontend:&lt;/span&gt;&lt;span class="n"&gt;nscp&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;unlock&lt;/span&gt; &lt;span class="n"&gt;myCache&lt;/span&gt;

    &lt;span class="nl"&gt;frontend:&lt;/span&gt;&lt;span class="n"&gt;nscp&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;findEntry&lt;/span&gt; &lt;span class="n"&gt;myCache&lt;/span&gt; &lt;span class="n"&gt;foo&lt;/span&gt;
    &lt;span class="n"&gt;eid0x619088&lt;/span&gt;
    &lt;span class="nl"&gt;frontend:&lt;/span&gt;&lt;span class="n"&gt;nscp&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getValue&lt;/span&gt; &lt;span class="n"&gt;eid0x619088&lt;/span&gt; &lt;span class="n"&gt;returnVar&lt;/span&gt;
    &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="nl"&gt;frontend:&lt;/span&gt;&lt;span class="n"&gt;nscp&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;set&lt;/span&gt; &lt;span class="n"&gt;returnVar&lt;/span&gt;
    &lt;span class="n"&gt;my&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id="best-practices"&gt;Best Practices&lt;/h2&gt;
&lt;p&gt;Creating a cache entry and setting a value in that entry MUST be made as a single transaction. An exclusion lock is provided to ensure this. If an error is thrown during this action, the cache would remain locked. A catch should be used around these actions to ensure proper unwinding of the entry and the lock: &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;    if {[catch {
        cache.lock &lt;span class="nv"&gt;$cacheName&lt;/span&gt;
        set entry [cache.createEntry &lt;span class="nv"&gt;$cacheName&lt;/span&gt; &lt;span class="nv"&gt;$key&lt;/span&gt; existsBoolean]
        cache.setValue &lt;span class="nv"&gt;$entry&lt;/span&gt; &lt;span class="nv"&gt;$value&lt;/span&gt;
        cache.unlock &lt;span class="nv"&gt;$cacheName&lt;/span&gt;
    }]} {
        set errorString &lt;span class="cp"&gt;${&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;errorInfo&lt;/span&gt;&lt;span class="cp"&gt;}&lt;/span&gt;
        catch {cache.flushEntry &lt;span class="nv"&gt;$entry&lt;/span&gt;}
        catch {cache.unlock &lt;span class="nv"&gt;$cacheName&lt;/span&gt;}
        error &lt;span class="nv"&gt;$errorString&lt;/span&gt;
    }
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Special attention should be paid to when and how named caches are created. The Cache API allows the creation of multiple caches of the same name, essentially overwriting the previous cache causing a memory leak. Because of this, the safest place for cache creation is at server startup, not in a procedure or page code. &lt;/p&gt;
&lt;p&gt;Need to document the BPs for wait, broadcast, and signal &lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Anonymous</dc:creator><pubDate>Wed, 01 Apr 2015 22:46:56 -0000</pubDate><guid>https://sourceforge.netbf06d145435223fa3c4a5a17431f0417566b3a4c</guid></item></channel></rss>