Cernunnos Manual


<cache>

Description:

Caches the object returned by the factory Phrase using the specified cache-key and makes it availbe under the key attribute.

Reagents:

Name XPath Description Reagent Type Expected Type Required
CACHE @cache A shared Map to cache items in. The default is the value of the 'Attributes.CACHE' request attribute. PHRASE java.util.Map No
CACHE_MODEL @cache-model Specify either NONE, ONE, or ALL. PHRASE java.lang.String No
KEY @key Attribute name the cached object will be bound to for subtasks. PHRASE java.lang.String Yes
CACHE_KEY @cache-key The cache key to use for caching the object. PHRASE java.io.Serializable Yes
TRHEAD_SAFE @thread-safe If the cached object is thread-safe or not. Defaults to false. PHRASE java.lang.String No
FACTORY @factory The Phrase to execute if the object isn't in the cache. PHRASE java.lang.Object No
SUBTASKS subtasks/* The set of tasks that are children of this cache task. NODE_LIST java.util.List No
FACTORY_TASKS factory/* The Tasks to execute if the object isn't in the cache. Specifying factory tasks will override the factory attribute NODE_LIST java.util.List No

Examples:

Executues a SQL query and caches the result under a custom key:

 
       
        <cache cache-key="STRUCTURE_STYLESHEET_ID.${STRUCTURE_STYLESHEET_NAME}" key="STRUCTURE_STYLESHEET_ID"> 
          <factory> 
            <sql-query> 
              <sql>SELECT SS_ID AS STRUCTURE_STYLESHEET_ID FROM UP_SS_STRUCT WHERE SS_NAME = ?</sql>  
              <parameter value="${STRUCTURE_STYLESHEET_NAME}"/>  
              <subtasks> 
                <return value="${STRUCTURE_STYLESHEET_ID}"/> 
              </subtasks> 
            </sql-query> 
          </factory>  
          <subtasks> 
            <return value="${STRUCTURE_STYLESHEET_ID}"/> 
          </subtasks> 
        </cache>