Login Register Wishes Forum About
Language Reference » pCache functions » writeToCache
Help topics
Latest updates
4669d  replaceImageMapTitle
4669d  replaceImageMapValues
4669d  createFunctionSerie
4669d  setAbsicssaPosition
4669d  negateValues
  Download as PDF
  Print this page
  Share this page
  Create an account
  Feed the updates!
Google AdSense
writeToCache - Push an object in the cache

This function allows you to push a rendered picture (object) in the static cache. Caching can greatly enhance the user experience of the people browsing your web application by lowering the web server CPU / memory usage and speed up the page rendering time. Every cached object must have an unique ID, see the getHash function for more information.

Calling this function

ID is the unique ID affected to this object.
pChartObject is the pChart object containing the picture you want to cache.

Sample script

 /* Include all the classes */ 

 /* Create your dataset object */ 
 $myData = new pData(); 
 /* Add data in your dataset */ 

 /* Create the cache object */
 $myCache = new pCache();

 /* Compute the hash linked to the chart data */
 $ChartHash = $myCache->getHash($myData);

 /* Test if we got this hash in our cache already */
 if ( $myCache->isInCache($ChartHash))
   /* If we have it, get the picture from the cache! */
   /* Create a pChart object and associate your dataset */ 
   $myPicture = new pImage(700,230,$myData);

   /* Choose a nice font */

   /* Define the boundaries of the graph area */

   /* Draw the scale, keep everything automatic */ 

   /* Draw the scale, keep everything automatic */ 

   /* Do some cosmetics */
   $myPicture->drawText(10,13,"Test of the pCache class",array("R"=>255,"G"=>255,"B"=>255));

   /* Push the rendered picture to the cache */

   /* Render the picture */

The first time that this code will be executed, the picture will be rendered and pushed in the cache, the next times, it will be retrieved from the cache directly saving CPU and execution time.
Last updated on 08/24/2010 
by Jean-Damien 
Linked resources
  There is no linked topic yet.
Community comments
  No comments have been posted yet.
© Copyrights
Components used on this web site : Famfamfam icons has been made by Mark James, Rounded corners lite has been coded by Cameron Cooke and Tim Hutchison, SyntaxHighlighter has been written by Alex Gorbatchev. pChart and this web site have been created by Jean-Damien POGOLOTTI. This documentation contains 185 pages and 56 comments. 415 users have registered. This page has been rendered in 0,01 seconds. Wiki revision 1.37.