Blame | Letzte Änderung | Log anzeigen | RSS feed
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1"><LINK REL="Start" HREF="index.html"><LINK REL="Contents" HREF="toc.html"><LINK REL="Prev" HREF="51Enablingthecachesystem.html"><LINK REL="Next" HREF="53UsingthecachewithClientSideImageMaps.html"><STYLE TYPE="text/css"><!--BODY { font-family: serif }H1 { font-family: sans-serif }H2 { font-family: sans-serif }H3 { font-family: sans-serif }H4 { font-family: sans-serif }H5 { font-family: sans-serif }H6 { font-family: sans-serif }SUB { font-size: smaller }SUP { font-size: smaller }PRE { font-family: monospace }A { text-decoration: none }--></STYLE></HEAD><BODY><A HREF="toc.html">Contents</A><A HREF="51Enablingthecachesystem.html">Previous</A><A HREF="53UsingthecachewithClientSideImageMaps.html">Next</A><HR NOSHADE><H2><A NAME="5_2">5.2 Using the cache in your script</A></H2><P> To use caching in your script you must supply a suitable file namewhich will be used to store the image in the cache. You can also supplya timeout value indicating how many minutes the cached image should beconsidered valid.</P><P> These parameters are supplied in the initial Graph() method callwhich should be among the first in your script. Instead of manuallyspecifying a file name to be used you could often use the special name"auto". If the filename is specified as "auto" the cashed image willthen be named the same as the image script but with the correctextension depending on what image format have been chosen.</P><P> If you don't specify a file name no caching will be used no matterthe settings of USE_CACHE (without a file name it is impossible!)</P><P> The following call to Graph() shows a typical use of the cache.</P><P><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB"> $graph </FONT><FONT color="#007700">= new </FONT><FONT color="#0000BB">Graph</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">300</FONT><FONTcolor="#007700">,</FONT><FONT color="#0000BB">200</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">"auto"</FONT><FONT color="#007700">,</FONT><FONTcolor="#0000BB">60</FONT><FONT color="#007700">)</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV></P><P></P><P> The above code will use the automatic filename and a make the cachevalid for 60 minutes.</P><P> So, how does this all work now?</P><P> The first time you call your script (no cached image) everythingwill be as usual, the script will run and you will in the end send backthe image to the browser. However if you have the caching enabledJpGraph will automatically have stored a copy of the generated image inthe cache directory.</P><P> The next time you call the script the first thing that happens inthe initial Graph() is that it will go and check in the cache directoryif the named image exists there. If this is the case it will alsochecks that the image isn't too old (as compared to the specifiedtimeout value). If the image is valid then the image will be streamedstraight back from the image file to the browser and the script willend it's execution.</P><P> Hence, if the image is found in the cache<STRONG> no code linesafter the initial Graph() call will be executed</STRONG></P><P> The design decision behind this is that your image script code neverhas to include anything special to make full use of the cache. It willjust automatically work.</P><HR NOSHADE><A HREF="toc.html">Contents</A><A HREF="51Enablingthecachesystem.html">Previous</A><A HREF="53UsingthecachewithClientSideImageMaps.html">Next</A></BODY></HTML>