Page: http://wiki.cocoondev.org/Wiki.jsp?page=WritingPipelineComponents , 
version: 4 on Wed May 14 16:33:03 2003 by SylvainWallez

- * __[Writing components for maximum cache 
efficiency|WritingForCacheEfficiency]__
+ * __[Writing efficient cacheable pipeline 
components|WritingForCacheEfficiency]__


Page: http://wiki.cocoondev.org/Wiki.jsp?page=WritingForCacheEfficiency , 
version: 2 on Wed May 14 16:32:11 2003 by SylvainWallez

+ There are a number of existing Cocoon components that implement this 
interface and that you can take as samples when writing your own.
+ 
+ However, here are a few tips that can help to achieve maximum efficiency.
+ 
+ ----
+ !!Avoiding uncessary operations
+ 
- However, achieving maximum performance to deliver cached content needs some 
careful coding.
? ^^^^^^^^^^

+ Achieving maximum performance to deliver cached content needs some careful 
coding of cacheable components.
? ^                                                                             
   ++++++++++++++++++++++++

- Here's a reminder of the various steps that occur when handling a request :\\
?                                                                            --

+ Here's a reminder of the various steps that occur when handling a request :
- __1__ - the sitemap is executed, meaning we create a pipeline object, and 
pipeline components : generator, transformers, and serializer.\\
? ^^^^^^^                                                                       
                                                          --

+ # the sitemap is executed, meaning we create a pipeline object, and pipeline 
components : generator, transformers, and serializer.
? ^

- __2__ - the {{setup()}} method of all pipeline components is called (except 
serializer which doesn't have one)\\
? ^^^^^^^                                                                       
                                --

+ # the {{setup()}} method of all pipeline components is called (except 
serializer which doesn't have one)
? ^

- __3__ - the {{getKey()}} method of all pipeline components is called
- 
- Knowing the key, the pipeline can get the associated cache entry and its 
validity. If the cache validity either is invalid or needs a fresh validity 
object to be compared with, then :\\
+ # the {{getKey()}} method of all pipeline components is called\\ \\Knowing 
the key, the pipeline can get the associated cache entry and its validity. If 
the cache validity either is invalid or needs a fresh validity object to be 
compared with, then :\\.
? +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++           
                                                                                
                                                                                
              +

- __4__ - the {{getValidity()}} method of all pipeline components is called
- 
- The pipeline can then know if the cache entry is valid. If it's valid, it 
delivers the cached content. If it's invalid, then :\\
+ # the {{getValidity()}} method of all pipeline components is called\\ \\The 
pipeline can then know if the cache entry is valid. If it's valid, it delivers 
the cached content. If it's invalid, then :\\.
? ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++      
                                                                                
                                          +

- __5__ - the pipeline is connected. This means {{setXMLConsumer()}} is called 
on transformers and {{setOutputStream()}} is called on the serializer\\
? ^^^^^^^                                                                       
                                                                    --

+ # the pipeline is connected. This means {{setXMLConsumer()}} is called on 
transformers and {{setOutputStream()}} is called on the serializer
? ^

- __6__ - the generator's {{generate()}} method is called, and starts the SAX 
stream processing, resulting first in {{startDocument()}} being called on 
transformers and serializer.
? ^^^^^^^

+ # the generator's {{generate()}} method is called, and starts the SAX stream 
processing, resulting first in {{startDocument()}} being called on transformers 
and serializer.
? ^

+ ----
+ !! Cache validity depends on pipeline execution
+ 
+ Some pipeline components have a validity that depends on the execution of the 
pipeline. Some examples include :
+ * the DirectoryGenerator : validity is the list of files whose XML 
representation is produced,
+ * the TraxTransformer : we need to track source included with the 
{{document()}} function.
+ 
+ How can such components be made cacheable, since {{getValidity()}} is called 
before pipeline execution (see above) ?
+ 
+ The solution used in the DirectoryGenerator is for {{getValidity()}} to 
return a validity object that is initially just an empty placeholder, and is 
filled with file names and modification dates during the pipeline execution 
phase. When pipeline execution is finished, the produced content goes into the 
cache with a validity object which is correctly filled.
+ 
+ Et voilĂ  ! Cache validity is actually computed during pipeline execution !
+ ----


Reply via email to