File: BaseCache.html

package info (click to toggle)
libhtml-mason-perl 1%3A1.39-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 2,072 kB
  • ctags: 1,535
  • sloc: perl: 17,624; sh: 187; makefile: 12
file content (100 lines) | stat: -rw-r--r-- 3,877 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>HTML::Mason::Cache::BaseCache - Base cache object</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root@localhost" />
</head>

<body style="background-color: white">

<p><A NAME="__index__"></a></p>
<!-- INDEX BEGIN -->

<ul>

	<li><A HREF="#name">NAME</a></li>
	<li><A HREF="#description">DESCRIPTION</a></li>
	<li><A HREF="#methods">METHODS</a></li>
</ul>
<!-- INDEX END -->

<hr />
<p>
</p>
<h1><A NAME="name">NAME</a></h1>
<p>HTML::Mason::Cache::BaseCache - Base cache object</p>
<p>
</p>
<hr />
<h1><A NAME="description">DESCRIPTION</a></h1>
<p>This is the base module for all cache implementations used in Mason.
It provides a few additional methods on top of <code>Cache::BaseCache</code> in
Dewitt Clinton's <code>Cache::Cache</code> package.</p>
<p>An object of this class is returned from <A HREF="../Request.html#item_cache">$m-&gt;cache</a>.</p>
<p>
</p>
<hr />
<h1><A NAME="methods">METHODS</a></h1>
<dl>
<dt><strong><A NAME="item_clear">clear ()</a></strong>

<A NAME="item_clear"></a><p>Remove all values in the cache.</p>
<dt><strong><A NAME="item_get">get (key, [%params])</a></strong>

<A NAME="item_get"></a><p>Returns the value associated with <em>key</em> or undef if it is
non-existent or expired. This is extended with the following optional
name/value parameters:</p>
<dl>
<dt><strong><A NAME="item_busy_lock__3d_3e_duration">busy_lock =&gt; duration</a></strong>

<dd>
<p>If the value has expired, set its expiration time to the current time plus
<em>duration</em> (instead of removing it from the cache) before returning undef.
This is used to prevent multiple processes from recomputing the same
expensive value simultaneously. The <em>duration</em> may be of any form acceptable
to <A HREF="../Cache/BaseCache.html#item_set">set</a>.</p>
</dd>
</li>
<dt><strong><A NAME="item_expire_if__3d_3e_sub">expire_if =&gt; sub</a></strong>

<dd>
<p>If the value exists and has not expired, call <em>sub</em> with the cache
object as a single parameter. If <em>sub</em> returns a true value, expire
the value.</p>
</dd>
</li>
</dl>
<dt><strong><A NAME="item_get_object">get_object (key)</a></strong>

<A NAME="item_get_object"></a><p>Returns the underlying <code>Cache::Object</code> object associated with <em>key</em>.
The most useful methods on this object are</p>
<pre>
    $co-&gt;get_created_at();    # when was object stored in cache
    $co-&gt;get_accessed_at();   # when was object last accessed
    $co-&gt;get_expires_at();    # when does object expire</pre>
<dt><strong><A NAME="item_expire">expire (key)</a></strong>

<A NAME="item_expire"></a><p>Expires the value associated with <em>key</em>, if it exists. Differs from
<A HREF="../Cache/BaseCache.html#item_remove">remove</a> only in that
the cache object is left around, e.g. for retrieval by
<A HREF="../Cache/BaseCache.html#item_get_object">get_object</a>.</p>
<dt><strong><A NAME="item_remove">remove (key)</a></strong>

<A NAME="item_remove"></a><p>Removes the cache object associated with <em>key</em>, if it exists.</p>
<dt><strong><A NAME="item_set">set (key, data, [duration])</a></strong>

<A NAME="item_set"></a><p>Associates <em>data</em> with <em>key</em> in the cache. <em>duration</em>
indicates the time until the value should be erased.  If
<em>duration</em> is unspecified, the value will never expire
by time.</p>
<p><em>$expires_in</em> may be a simple number of seconds, or a string of the
form ``[number] [unit]'', e.g., ``10 minutes''.  The valid units are s,
second, seconds, sec, m, minute, minutes, min, h, hour, hours, d, day,
days, w, week, weeks, M, month, months, y, year, and years.</p>
</dl>

</body>

</html>