Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
2
<HTML>
3
<HEAD>
4
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
5
<LINK REL="Start" HREF="index.html">
6
<LINK REL="Contents" HREF="toc.html">
7
<LINK REL="Prev" HREF="61Enablingthecachesystem.html">
8
<LINK REL="Next" HREF="63UsingthecachewithClientSideImageMaps.html">
9
<STYLE TYPE="text/css"><!--
10
BODY { font-family: serif }
11
H1 { font-family: sans-serif }
12
H2 { font-family: sans-serif }
13
H3 { font-family: sans-serif }
14
H4 { font-family: sans-serif }
15
H5 { font-family: sans-serif }
16
H6 { font-family: sans-serif }
17
SUB { font-size: smaller }
18
SUP { font-size: smaller }
19
PRE { font-family: monospace }
20
A { text-decoration: none }
21
--></STYLE>
22
</HEAD>
23
<BODY>
24
<A HREF="toc.html">Contents</A>
25
<A HREF="61Enablingthecachesystem.html">Previous</A>
26
<A HREF="63UsingthecachewithClientSideImageMaps.html">Next</A>
27
<HR NOSHADE>
28
<H2><A NAME="6_2">6.2 Using the cache in your script</A></H2>
29
<P> To use caching in your script you must supply a suitable file name
30
 which will be used to store the image in the cache. You can also supply
31
 a timeout value indicating how many minutes the cached image should be
32
 considered valid.</P>
33
<P> These parameters are supplied in the initial Graph() method call
34
 which should be among the first in your script. Instead of manually
35
 specifying a file name to be used you could often use the special name
36
 &quot;auto&quot;. If the filename is specified as &quot;auto&quot; the cashed image will
37
 then be named the same as the image script but with the correct
38
 extension depending on what image format have been chosen.</P>
39
<P> If you don't specify a file name no caching will be used no matter
40
 the settings of USE_CACHE (without a file name it is impossible!)</P>
41
<P> The following call to Graph() shows a typical use of the cache.</P>
42
<P><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
43
&nbsp;$graph&nbsp;</FONT><FONT color="#007700">=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">
44
Graph</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">300</FONT><FONT
45
color="#007700">,</FONT><FONT color="#0000BB">200</FONT><FONT color="#007700">
46
,</FONT><FONT color="#DD0000">&quot;auto&quot;</FONT><FONT color="#007700">,</FONT><FONT
47
color="#0000BB">60</FONT><FONT color="#007700">)</FONT><FONT color="#0000BB">
48
</FONT></FONT></CODE></DIV></P>
49
<P></P>
50
<P> The above code will use the automatic filename and a make the cache
51
 valid for 60 minutes.</P>
52
<P> So, how does this all work now?</P>
53
<P> The first time you call your script (no cached image) everything
54
 will be as usual, the script will run and you will in the end send back
55
 the image to the browser. However if you have the caching enabled
56
 JpGraph will automatically have stored a copy of the generated image in
57
 the cache directory.</P>
58
<P> The next time you call the script the first thing that happens in
59
 the initial Graph() is that it will go and check in the cache directory
60
 if the named image exists there. If this is the case it will also
61
 checks that the image isn't too old (as compared to the specified
62
 timeout value). If the image is valid then the image will be streamed
63
 straight back from the image file to the browser and the script will
64
 end it's execution.</P>
65
<P> Hence, if the image is found in the cache<STRONG> no code lines
66
 after the initial Graph() call will be executed</STRONG></P>
67
<P> The design decision behind this is that your image script code never
68
 has to include anything special to make full use of the cache. It will
69
 just automatically work.</P>
70
<HR NOSHADE>
71
<A HREF="toc.html">Contents</A>
72
<A HREF="61Enablingthecachesystem.html">Previous</A>
73
<A HREF="63UsingthecachewithClientSideImageMaps.html">Next</A>
74
</BODY>
75
</HTML>