cachetastic 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/cachetastic.rb +1 -1
- metadata +2 -30
- data/doc/classes/Cachetastic/Adapters.html +0 -180
- data/doc/classes/Cachetastic/Adapters/Base.html +0 -419
- data/doc/classes/Cachetastic/Adapters/File.html +0 -135
- data/doc/classes/Cachetastic/Adapters/LocalMemory.html +0 -125
- data/doc/classes/Cachetastic/Adapters/Memcached.html +0 -193
- data/doc/classes/Cachetastic/Cache.html +0 -425
- data/doc/classes/Cachetastic/Cacheable.html +0 -255
- data/doc/classes/Cachetastic/Cacheable/ClassAndInstanceMethods.html +0 -290
- data/doc/classes/Cachetastic/Cacheable/ClassOnlyMethods.html +0 -197
- data/doc/classes/Cachetastic/Logger.html +0 -186
- data/doc/created.rid +0 -1
- data/doc/files/LICENSE.html +0 -132
- data/doc/files/README.html +0 -222
- data/doc/files/lib/cachetastic/adapters/base_rb.html +0 -101
- data/doc/files/lib/cachetastic/adapters/file_rb.html +0 -101
- data/doc/files/lib/cachetastic/adapters/local_memory_rb.html +0 -101
- data/doc/files/lib/cachetastic/adapters/memcached_rb.html +0 -101
- data/doc/files/lib/cachetastic/cache_rb.html +0 -101
- data/doc/files/lib/cachetastic/cacheable_rb.html +0 -101
- data/doc/files/lib/cachetastic/extensions/string_rb.html +0 -108
- data/doc/files/lib/cachetastic/logger_rb.html +0 -101
- data/doc/files/lib/cachetastic/store_object_rb.html +0 -101
- data/doc/files/lib/cachetastic_rb.html +0 -112
- data/doc/fr_class_index.html +0 -36
- data/doc/fr_file_index.html +0 -38
- data/doc/fr_method_index.html +0 -52
- data/doc/index.html +0 -24
- data/doc/rdoc-style.css +0 -208
@@ -1,425 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
-
<head>
|
8
|
-
<title>Class: Cachetastic::Cache</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
-
<script type="text/javascript">
|
13
|
-
// <![CDATA[
|
14
|
-
|
15
|
-
function popupCode( url ) {
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
-
}
|
18
|
-
|
19
|
-
function toggleCode( id ) {
|
20
|
-
if ( document.getElementById )
|
21
|
-
elem = document.getElementById( id );
|
22
|
-
else if ( document.all )
|
23
|
-
elem = eval( "document.all." + id );
|
24
|
-
else
|
25
|
-
return false;
|
26
|
-
|
27
|
-
elemStyle = elem.style;
|
28
|
-
|
29
|
-
if ( elemStyle.display != "block" ) {
|
30
|
-
elemStyle.display = "block"
|
31
|
-
} else {
|
32
|
-
elemStyle.display = "none"
|
33
|
-
}
|
34
|
-
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Make codeblocks hidden by default
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
-
|
41
|
-
// ]]>
|
42
|
-
</script>
|
43
|
-
|
44
|
-
</head>
|
45
|
-
<body>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<div id="classHeader">
|
50
|
-
<table class="header-table">
|
51
|
-
<tr class="top-aligned-row">
|
52
|
-
<td><strong>Class</strong></td>
|
53
|
-
<td class="class-name-in-header">Cachetastic::Cache</td>
|
54
|
-
</tr>
|
55
|
-
<tr class="top-aligned-row">
|
56
|
-
<td><strong>In:</strong></td>
|
57
|
-
<td>
|
58
|
-
<a href="../../files/lib/cachetastic/cache_rb.html">
|
59
|
-
lib/cachetastic/cache.rb
|
60
|
-
</a>
|
61
|
-
<br />
|
62
|
-
<a href="../../files/lib/cachetastic/store_object_rb.html">
|
63
|
-
lib/cachetastic/store_object.rb
|
64
|
-
</a>
|
65
|
-
<br />
|
66
|
-
</td>
|
67
|
-
</tr>
|
68
|
-
|
69
|
-
<tr class="top-aligned-row">
|
70
|
-
<td><strong>Parent:</strong></td>
|
71
|
-
<td>
|
72
|
-
Object
|
73
|
-
</td>
|
74
|
-
</tr>
|
75
|
-
</table>
|
76
|
-
</div>
|
77
|
-
<!-- banner header -->
|
78
|
-
|
79
|
-
<div id="bodyContent">
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
<div id="contextContent">
|
84
|
-
|
85
|
-
<div id="description">
|
86
|
-
<p>
|
87
|
-
When creating a new ‘<a href="Cache.html">Cache</a>’ this class
|
88
|
-
should be extended. Once extended you‘ll only need to override just
|
89
|
-
the methods that are different for your cache.
|
90
|
-
</p>
|
91
|
-
<pre>
|
92
|
-
class MyAwesomeCache < Cachetastic::Cache
|
93
|
-
end
|
94
|
-
|
95
|
-
MyAwesomeCache.set(1, "One")
|
96
|
-
MyAwesomeCache.get(1) # => "One"
|
97
|
-
MyAwesomeCache.update(1, "One!!")
|
98
|
-
MyAwesomeCache.get(1) # => "One!!"
|
99
|
-
MyAwesomeCache.delete(1)
|
100
|
-
MyAwesomeCache.get(1) # => nil
|
101
|
-
|
102
|
-
class MyAwesomeCache < Cachetastic::Cache
|
103
|
-
class << self
|
104
|
-
def get(key)
|
105
|
-
super(key) do
|
106
|
-
set(key, key * 10)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
MyAwesomeCache.set(1, "One")
|
113
|
-
MyAwesomeCache.get(1) # => "One"
|
114
|
-
MyAwesomeCache.delete(1)
|
115
|
-
MyAwesomeCache.get(1) # => 10
|
116
|
-
</pre>
|
117
|
-
|
118
|
-
</div>
|
119
|
-
|
120
|
-
|
121
|
-
</div>
|
122
|
-
|
123
|
-
<div id="method-list">
|
124
|
-
<h3 class="section-bar">Methods</h3>
|
125
|
-
|
126
|
-
<div class="name-list">
|
127
|
-
<a href="#M000022">adapter</a>
|
128
|
-
<a href="#M000025">calculate_expiry_time</a>
|
129
|
-
<a href="#M000023">clear_adapter!</a>
|
130
|
-
<a href="#M000020">delete</a>
|
131
|
-
<a href="#M000021">expire_all</a>
|
132
|
-
<a href="#M000018">get</a>
|
133
|
-
<a href="#M000024">logger</a>
|
134
|
-
<a href="#M000019">set</a>
|
135
|
-
</div>
|
136
|
-
</div>
|
137
|
-
|
138
|
-
</div>
|
139
|
-
|
140
|
-
|
141
|
-
<!-- if includes -->
|
142
|
-
|
143
|
-
<div id="section">
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
<!-- if method_list -->
|
153
|
-
<div id="methods">
|
154
|
-
<h3 class="section-bar">Public Class methods</h3>
|
155
|
-
|
156
|
-
<div id="method-M000022" class="method-detail">
|
157
|
-
<a name="M000022"></a>
|
158
|
-
|
159
|
-
<div class="method-heading">
|
160
|
-
<a href="#M000022" class="method-signature">
|
161
|
-
<span class="method-name">adapter</span><span class="method-args">()</span>
|
162
|
-
</a>
|
163
|
-
</div>
|
164
|
-
|
165
|
-
<div class="method-description">
|
166
|
-
<p>
|
167
|
-
Returns the underlying <a
|
168
|
-
href="Adapters/Base.html">Cachetastic::Adapters::Base</a> for this cache.
|
169
|
-
</p>
|
170
|
-
<p><a class="source-toggle" href="#"
|
171
|
-
onclick="toggleCode('M000022-source');return false;">[Source]</a></p>
|
172
|
-
<div class="method-source-code" id="M000022-source">
|
173
|
-
<pre>
|
174
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/cache.rb, line 79</span>
|
175
|
-
79: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">adapter</span>
|
176
|
-
80: <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@_adapter</span> <span class="ruby-operator">&&</span> <span class="ruby-ivar">@_adapter</span>.<span class="ruby-identifier">valid?</span>
|
177
|
-
81: <span class="ruby-ivar">@_adapter</span> = <span class="ruby-constant">Cachetastic</span><span class="ruby-operator">::</span><span class="ruby-constant">Adapters</span>.<span class="ruby-identifier">build</span>(<span class="ruby-identifier">cache_klass</span>)
|
178
|
-
82: <span class="ruby-keyword kw">end</span>
|
179
|
-
83: <span class="ruby-ivar">@_adapter</span>
|
180
|
-
84: <span class="ruby-keyword kw">end</span>
|
181
|
-
</pre>
|
182
|
-
</div>
|
183
|
-
</div>
|
184
|
-
</div>
|
185
|
-
|
186
|
-
<div id="method-M000023" class="method-detail">
|
187
|
-
<a name="M000023"></a>
|
188
|
-
|
189
|
-
<div class="method-heading">
|
190
|
-
<a href="#M000023" class="method-signature">
|
191
|
-
<span class="method-name">clear_adapter!</span><span class="method-args">()</span>
|
192
|
-
</a>
|
193
|
-
</div>
|
194
|
-
|
195
|
-
<div class="method-description">
|
196
|
-
<p>
|
197
|
-
Clears the <a href="Cache.html#M000022">adapter</a> so it can be redefined.
|
198
|
-
This is useful if you have reconfigured the cache to use a different
|
199
|
-
adapater, or different settings.
|
200
|
-
</p>
|
201
|
-
<p><a class="source-toggle" href="#"
|
202
|
-
onclick="toggleCode('M000023-source');return false;">[Source]</a></p>
|
203
|
-
<div class="method-source-code" id="M000023-source">
|
204
|
-
<pre>
|
205
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/cache.rb, line 88</span>
|
206
|
-
88: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">clear_adapter!</span>
|
207
|
-
89: <span class="ruby-ivar">@_adapter</span> = <span class="ruby-keyword kw">nil</span>
|
208
|
-
90: <span class="ruby-keyword kw">end</span>
|
209
|
-
</pre>
|
210
|
-
</div>
|
211
|
-
</div>
|
212
|
-
</div>
|
213
|
-
|
214
|
-
<div id="method-M000020" class="method-detail">
|
215
|
-
<a name="M000020"></a>
|
216
|
-
|
217
|
-
<div class="method-heading">
|
218
|
-
<a href="#M000020" class="method-signature">
|
219
|
-
<span class="method-name">delete</span><span class="method-args">(key)</span>
|
220
|
-
</a>
|
221
|
-
</div>
|
222
|
-
|
223
|
-
<div class="method-description">
|
224
|
-
<p>
|
225
|
-
Deletes an object from the cache.
|
226
|
-
</p>
|
227
|
-
<p><a class="source-toggle" href="#"
|
228
|
-
onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
|
229
|
-
<div class="method-source-code" id="M000020-source">
|
230
|
-
<pre>
|
231
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/cache.rb, line 63</span>
|
232
|
-
63: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete</span>(<span class="ruby-identifier">key</span>)
|
233
|
-
64: <span class="ruby-identifier">do_with_logging</span>(<span class="ruby-identifier">:delete</span>, <span class="ruby-identifier">key</span>) <span class="ruby-keyword kw">do</span>
|
234
|
-
65: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">adapter</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">key</span>)
|
235
|
-
66: <span class="ruby-keyword kw">nil</span>
|
236
|
-
67: <span class="ruby-keyword kw">end</span>
|
237
|
-
68: <span class="ruby-keyword kw">end</span>
|
238
|
-
</pre>
|
239
|
-
</div>
|
240
|
-
</div>
|
241
|
-
</div>
|
242
|
-
|
243
|
-
<div id="method-M000021" class="method-detail">
|
244
|
-
<a name="M000021"></a>
|
245
|
-
|
246
|
-
<div class="method-heading">
|
247
|
-
<a href="#M000021" class="method-signature">
|
248
|
-
<span class="method-name">expire_all</span><span class="method-args">()</span>
|
249
|
-
</a>
|
250
|
-
</div>
|
251
|
-
|
252
|
-
<div class="method-description">
|
253
|
-
<p>
|
254
|
-
Expires all objects for this cache.
|
255
|
-
</p>
|
256
|
-
<p><a class="source-toggle" href="#"
|
257
|
-
onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
|
258
|
-
<div class="method-source-code" id="M000021-source">
|
259
|
-
<pre>
|
260
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/cache.rb, line 71</span>
|
261
|
-
71: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">expire_all</span>
|
262
|
-
72: <span class="ruby-identifier">do_with_logging</span>(<span class="ruby-identifier">:expire_all</span>, <span class="ruby-keyword kw">nil</span>) <span class="ruby-keyword kw">do</span>
|
263
|
-
73: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">adapter</span>.<span class="ruby-identifier">expire_all</span>
|
264
|
-
74: <span class="ruby-keyword kw">nil</span>
|
265
|
-
75: <span class="ruby-keyword kw">end</span>
|
266
|
-
76: <span class="ruby-keyword kw">end</span>
|
267
|
-
</pre>
|
268
|
-
</div>
|
269
|
-
</div>
|
270
|
-
</div>
|
271
|
-
|
272
|
-
<div id="method-M000018" class="method-detail">
|
273
|
-
<a name="M000018"></a>
|
274
|
-
|
275
|
-
<div class="method-heading">
|
276
|
-
<a href="#M000018" class="method-signature">
|
277
|
-
<span class="method-name">get</span><span class="method-args">(key, &block)</span>
|
278
|
-
</a>
|
279
|
-
</div>
|
280
|
-
|
281
|
-
<div class="method-description">
|
282
|
-
<p>
|
283
|
-
Returns an object from the cache for a given key. If the object comes back
|
284
|
-
as nil and a block is given that block will be run and the results of the
|
285
|
-
block will be returned. This can be used to JIT caches, just make sure in
|
286
|
-
the block to call the <a href="Cache.html#M000019">set</a> method because
|
287
|
-
the results of the block are not automatically cached.
|
288
|
-
</p>
|
289
|
-
<p><a class="source-toggle" href="#"
|
290
|
-
onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
|
291
|
-
<div class="method-source-code" id="M000018-source">
|
292
|
-
<pre>
|
293
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/cache.rb, line 41</span>
|
294
|
-
41: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get</span>(<span class="ruby-identifier">key</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
295
|
-
42: <span class="ruby-identifier">do_with_logging</span>(<span class="ruby-identifier">:get</span>, <span class="ruby-identifier">key</span>) <span class="ruby-keyword kw">do</span>
|
296
|
-
43: <span class="ruby-identifier">val</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">adapter</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">key</span>)
|
297
|
-
44: <span class="ruby-identifier">handle_store_object</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">adapter</span>.<span class="ruby-identifier">unmarshal</span>(<span class="ruby-identifier">val</span>), <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
298
|
-
45: <span class="ruby-keyword kw">end</span>
|
299
|
-
46: <span class="ruby-keyword kw">end</span>
|
300
|
-
</pre>
|
301
|
-
</div>
|
302
|
-
</div>
|
303
|
-
</div>
|
304
|
-
|
305
|
-
<div id="method-M000024" class="method-detail">
|
306
|
-
<a name="M000024"></a>
|
307
|
-
|
308
|
-
<div class="method-heading">
|
309
|
-
<a href="#M000024" class="method-signature">
|
310
|
-
<span class="method-name">logger</span><span class="method-args">()</span>
|
311
|
-
</a>
|
312
|
-
</div>
|
313
|
-
|
314
|
-
<div class="method-description">
|
315
|
-
<p>
|
316
|
-
Returns the <a href="Logger.html">Cachetastic::Logger</a> for this cache.
|
317
|
-
</p>
|
318
|
-
<p><a class="source-toggle" href="#"
|
319
|
-
onclick="toggleCode('M000024-source');return false;">[Source]</a></p>
|
320
|
-
<div class="method-source-code" id="M000024-source">
|
321
|
-
<pre>
|
322
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/cache.rb, line 97</span>
|
323
|
-
97: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">logger</span>
|
324
|
-
98: <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@_logger</span>
|
325
|
-
99: <span class="ruby-ivar">@_logger</span> = <span class="ruby-constant">Cachetastic</span><span class="ruby-operator">::</span><span class="ruby-constant">Logger</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">adapter</span>.<span class="ruby-identifier">logger</span>)
|
326
|
-
100: <span class="ruby-keyword kw">end</span>
|
327
|
-
101: <span class="ruby-ivar">@_logger</span>
|
328
|
-
102: <span class="ruby-keyword kw">end</span>
|
329
|
-
</pre>
|
330
|
-
</div>
|
331
|
-
</div>
|
332
|
-
</div>
|
333
|
-
|
334
|
-
<div id="method-M000019" class="method-detail">
|
335
|
-
<a name="M000019"></a>
|
336
|
-
|
337
|
-
<div class="method-heading">
|
338
|
-
<a href="#M000019" class="method-signature">
|
339
|
-
<span class="method-name">set</span><span class="method-args">(key, value, expiry_time = nil)</span>
|
340
|
-
</a>
|
341
|
-
</div>
|
342
|
-
|
343
|
-
<div class="method-description">
|
344
|
-
<p>
|
345
|
-
Set a particular object info the cache for the given key.
|
346
|
-
</p>
|
347
|
-
<p>
|
348
|
-
An optional third parameter sets the expiry time for the object in the
|
349
|
-
cache. If no expiry_time is passed in then the default expiry_time that has
|
350
|
-
been configured will be used.
|
351
|
-
</p>
|
352
|
-
<p>
|
353
|
-
If there is an the expiry_swing setting is configured it will be +/- to the
|
354
|
-
expiry time.
|
355
|
-
</p>
|
356
|
-
<p><a class="source-toggle" href="#"
|
357
|
-
onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
|
358
|
-
<div class="method-source-code" id="M000019-source">
|
359
|
-
<pre>
|
360
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/cache.rb, line 56</span>
|
361
|
-
56: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">expiry_time</span> = <span class="ruby-keyword kw">nil</span>)
|
362
|
-
57: <span class="ruby-identifier">do_with_logging</span>(<span class="ruby-identifier">:set</span>, <span class="ruby-identifier">key</span>) <span class="ruby-keyword kw">do</span>
|
363
|
-
58: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">adapter</span>.<span class="ruby-identifier">set</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">calculate_expiry_time</span>(<span class="ruby-identifier">expiry_time</span>))
|
364
|
-
59: <span class="ruby-keyword kw">end</span>
|
365
|
-
60: <span class="ruby-keyword kw">end</span>
|
366
|
-
</pre>
|
367
|
-
</div>
|
368
|
-
</div>
|
369
|
-
</div>
|
370
|
-
|
371
|
-
<h3 class="section-bar">Private Class methods</h3>
|
372
|
-
|
373
|
-
<div id="method-M000025" class="method-detail">
|
374
|
-
<a name="M000025"></a>
|
375
|
-
|
376
|
-
<div class="method-heading">
|
377
|
-
<a href="#M000025" class="method-signature">
|
378
|
-
<span class="method-name">calculate_expiry_time</span><span class="method-args">(expiry_time)</span>
|
379
|
-
</a>
|
380
|
-
</div>
|
381
|
-
|
382
|
-
<div class="method-description">
|
383
|
-
<p>
|
384
|
-
If the expiry time is <a href="Cache.html#M000019">set</a> to 60 minutes
|
385
|
-
and the expiry_swing time is <a href="Cache.html#M000019">set</a> to 15
|
386
|
-
minutes, this method will return a number between 45 minutes and 75
|
387
|
-
minutes.
|
388
|
-
</p>
|
389
|
-
<p><a class="source-toggle" href="#"
|
390
|
-
onclick="toggleCode('M000025-source');return false;">[Source]</a></p>
|
391
|
-
<div class="method-source-code" id="M000025-source">
|
392
|
-
<pre>
|
393
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/cache.rb, line 107</span>
|
394
|
-
107: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">calculate_expiry_time</span>(<span class="ruby-identifier">expiry_time</span>) <span class="ruby-comment cmt"># :doc:</span>
|
395
|
-
108: <span class="ruby-identifier">expiry_time</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">adapter</span>.<span class="ruby-identifier">default_expiry</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">expiry_time</span>.<span class="ruby-identifier">nil?</span>
|
396
|
-
109: <span class="ruby-identifier">exp_swing</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">adapter</span>.<span class="ruby-identifier">expiry_swing</span>
|
397
|
-
110: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">exp_swing</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">exp_swing</span> <span class="ruby-operator">!=</span> <span class="ruby-value">0</span>
|
398
|
-
111: <span class="ruby-identifier">swing</span> = <span class="ruby-identifier">rand</span>(<span class="ruby-identifier">exp_swing</span>.<span class="ruby-identifier">to_i</span>)
|
399
|
-
112: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">rand</span>(<span class="ruby-value">2</span>)
|
400
|
-
113: <span class="ruby-keyword kw">when</span> <span class="ruby-value">0</span>
|
401
|
-
114: <span class="ruby-identifier">expiry_time</span> = (<span class="ruby-identifier">expiry_time</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">swing</span>)
|
402
|
-
115: <span class="ruby-keyword kw">when</span> <span class="ruby-value">1</span>
|
403
|
-
116: <span class="ruby-identifier">expiry_time</span> = (<span class="ruby-identifier">expiry_time</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">swing</span>)
|
404
|
-
117: <span class="ruby-keyword kw">end</span>
|
405
|
-
118: <span class="ruby-keyword kw">end</span>
|
406
|
-
119: <span class="ruby-identifier">expiry_time</span>
|
407
|
-
120: <span class="ruby-keyword kw">end</span>
|
408
|
-
</pre>
|
409
|
-
</div>
|
410
|
-
</div>
|
411
|
-
</div>
|
412
|
-
|
413
|
-
|
414
|
-
</div>
|
415
|
-
|
416
|
-
|
417
|
-
</div>
|
418
|
-
|
419
|
-
|
420
|
-
<div id="validator-badges">
|
421
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
422
|
-
</div>
|
423
|
-
|
424
|
-
</body>
|
425
|
-
</html>
|
@@ -1,255 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
-
<!DOCTYPE html
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
-
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
-
<head>
|
8
|
-
<title>Module: Cachetastic::Cacheable</title>
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
-
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
12
|
-
<script type="text/javascript">
|
13
|
-
// <![CDATA[
|
14
|
-
|
15
|
-
function popupCode( url ) {
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
-
}
|
18
|
-
|
19
|
-
function toggleCode( id ) {
|
20
|
-
if ( document.getElementById )
|
21
|
-
elem = document.getElementById( id );
|
22
|
-
else if ( document.all )
|
23
|
-
elem = eval( "document.all." + id );
|
24
|
-
else
|
25
|
-
return false;
|
26
|
-
|
27
|
-
elemStyle = elem.style;
|
28
|
-
|
29
|
-
if ( elemStyle.display != "block" ) {
|
30
|
-
elemStyle.display = "block"
|
31
|
-
} else {
|
32
|
-
elemStyle.display = "none"
|
33
|
-
}
|
34
|
-
|
35
|
-
return true;
|
36
|
-
}
|
37
|
-
|
38
|
-
// Make codeblocks hidden by default
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
-
|
41
|
-
// ]]>
|
42
|
-
</script>
|
43
|
-
|
44
|
-
</head>
|
45
|
-
<body>
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
<div id="classHeader">
|
50
|
-
<table class="header-table">
|
51
|
-
<tr class="top-aligned-row">
|
52
|
-
<td><strong>Module</strong></td>
|
53
|
-
<td class="class-name-in-header">Cachetastic::Cacheable</td>
|
54
|
-
</tr>
|
55
|
-
<tr class="top-aligned-row">
|
56
|
-
<td><strong>In:</strong></td>
|
57
|
-
<td>
|
58
|
-
<a href="../../files/lib/cachetastic/cacheable_rb.html">
|
59
|
-
lib/cachetastic/cacheable.rb
|
60
|
-
</a>
|
61
|
-
<br />
|
62
|
-
</td>
|
63
|
-
</tr>
|
64
|
-
|
65
|
-
</table>
|
66
|
-
</div>
|
67
|
-
<!-- banner header -->
|
68
|
-
|
69
|
-
<div id="bodyContent">
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
<div id="contextContent">
|
74
|
-
|
75
|
-
<div id="description">
|
76
|
-
<p>
|
77
|
-
Include this module into an Object to achieve simplistic Object level
|
78
|
-
caching.
|
79
|
-
</p>
|
80
|
-
<p>
|
81
|
-
Example:
|
82
|
-
</p>
|
83
|
-
<pre>
|
84
|
-
class Person
|
85
|
-
include Cachetastic::Cacheable
|
86
|
-
|
87
|
-
attr_accessor :name
|
88
|
-
|
89
|
-
def cachetastic_key
|
90
|
-
self.name
|
91
|
-
end
|
92
|
-
|
93
|
-
def always_the_same(x, y)
|
94
|
-
cacher("always_the_same") do
|
95
|
-
x + y
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
end
|
100
|
-
</pre>
|
101
|
-
|
102
|
-
</div>
|
103
|
-
|
104
|
-
|
105
|
-
</div>
|
106
|
-
|
107
|
-
<div id="method-list">
|
108
|
-
<h3 class="section-bar">Methods</h3>
|
109
|
-
|
110
|
-
<div class="name-list">
|
111
|
-
<a href="#M000010">cache_self</a>
|
112
|
-
<a href="#M000011">uncache_self</a>
|
113
|
-
</div>
|
114
|
-
</div>
|
115
|
-
|
116
|
-
</div>
|
117
|
-
|
118
|
-
|
119
|
-
<!-- if includes -->
|
120
|
-
|
121
|
-
<div id="section">
|
122
|
-
|
123
|
-
<div id="class-list">
|
124
|
-
<h3 class="section-bar">Classes and Modules</h3>
|
125
|
-
|
126
|
-
Module <a href="Cacheable/ClassAndInstanceMethods.html" class="link">Cachetastic::Cacheable::ClassAndInstanceMethods</a><br />
|
127
|
-
Module <a href="Cacheable/ClassOnlyMethods.html" class="link">Cachetastic::Cacheable::ClassOnlyMethods</a><br />
|
128
|
-
|
129
|
-
</div>
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
<!-- if method_list -->
|
138
|
-
<div id="methods">
|
139
|
-
<h3 class="section-bar">Public Instance methods</h3>
|
140
|
-
|
141
|
-
<div id="method-M000010" class="method-detail">
|
142
|
-
<a name="M000010"></a>
|
143
|
-
|
144
|
-
<div class="method-heading">
|
145
|
-
<a href="#M000010" class="method-signature">
|
146
|
-
<span class="method-name">cache_self</span><span class="method-args">()</span>
|
147
|
-
</a>
|
148
|
-
</div>
|
149
|
-
|
150
|
-
<div class="method-description">
|
151
|
-
<p>
|
152
|
-
Unless the object‘s cachetastic_key method returns nil this method
|
153
|
-
will store the object in the cache using the object‘s cachetastic_key
|
154
|
-
as the key. You <b>MUST</b> create an instance level method called
|
155
|
-
cachetastic_key and have it return a valid key! If you return nil from the
|
156
|
-
cachetastic_key method or you will not be able to use the <a
|
157
|
-
href="Cacheable.html#M000010">cache_self</a> and <a
|
158
|
-
href="Cacheable.html#M000011">uncache_self</a> methods.
|
159
|
-
</p>
|
160
|
-
<p>
|
161
|
-
Example:
|
162
|
-
</p>
|
163
|
-
<pre>
|
164
|
-
class Person
|
165
|
-
include Cachetastic::Cacheable
|
166
|
-
attr_accessor :name
|
167
|
-
def cachetastic_key
|
168
|
-
self.name
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
Person.get_from_cache("Mark Bates") # => nil
|
173
|
-
p = Person.new
|
174
|
-
p.name = "Mark Bates"
|
175
|
-
p.cache_self
|
176
|
-
Person.get_from_cache("Mark Bates") # => "Mark Bates"
|
177
|
-
</pre>
|
178
|
-
<p><a class="source-toggle" href="#"
|
179
|
-
onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
|
180
|
-
<div class="method-source-code" id="M000010-source">
|
181
|
-
<pre>
|
182
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/cacheable.rb, line 146</span>
|
183
|
-
146: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cache_self</span>
|
184
|
-
147: <span class="ruby-identifier">cache_class</span>.<span class="ruby-identifier">set</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">cachetastic_key</span>, <span class="ruby-keyword kw">self</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">cachetastic_key</span>.<span class="ruby-identifier">nil?</span>
|
185
|
-
148: <span class="ruby-keyword kw">end</span>
|
186
|
-
</pre>
|
187
|
-
</div>
|
188
|
-
</div>
|
189
|
-
</div>
|
190
|
-
|
191
|
-
<div id="method-M000011" class="method-detail">
|
192
|
-
<a name="M000011"></a>
|
193
|
-
|
194
|
-
<div class="method-heading">
|
195
|
-
<a href="#M000011" class="method-signature">
|
196
|
-
<span class="method-name">uncache_self</span><span class="method-args">()</span>
|
197
|
-
</a>
|
198
|
-
</div>
|
199
|
-
|
200
|
-
<div class="method-description">
|
201
|
-
<p>
|
202
|
-
Unless the object‘s cachetastic_key method returns nil this method
|
203
|
-
will delete the object in the cache using the object‘s
|
204
|
-
cachetastic_key as the key. You <b>MUST</b> create an instance level method
|
205
|
-
called cachetastic_key and have it return a valid key! If you return nil
|
206
|
-
from the cachetastic_key method or you will not be able to use the <a
|
207
|
-
href="Cacheable.html#M000010">cache_self</a> and <a
|
208
|
-
href="Cacheable.html#M000011">uncache_self</a> methods.
|
209
|
-
</p>
|
210
|
-
<p>
|
211
|
-
Example:
|
212
|
-
</p>
|
213
|
-
<pre>
|
214
|
-
class Person
|
215
|
-
include Cachetastic::Cacheable
|
216
|
-
attr_accessor :name
|
217
|
-
def cachetastic_key
|
218
|
-
self.name
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
Person.get_from_cache("Mark Bates") # => nil
|
223
|
-
p = Person.new
|
224
|
-
p.name = "Mark Bates"
|
225
|
-
p.cache_self
|
226
|
-
Person.get_from_cache("Mark Bates") # => "Mark Bates"
|
227
|
-
p.uncache_self
|
228
|
-
Person.get_from_cache("Mark Bates") # => nil
|
229
|
-
</pre>
|
230
|
-
<p><a class="source-toggle" href="#"
|
231
|
-
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
|
232
|
-
<div class="method-source-code" id="M000011-source">
|
233
|
-
<pre>
|
234
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/cacheable.rb, line 172</span>
|
235
|
-
172: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">uncache_self</span>
|
236
|
-
173: <span class="ruby-identifier">cache_class</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">cachetastic_key</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">cachetastic_key</span>.<span class="ruby-identifier">nil?</span>
|
237
|
-
174: <span class="ruby-keyword kw">end</span>
|
238
|
-
</pre>
|
239
|
-
</div>
|
240
|
-
</div>
|
241
|
-
</div>
|
242
|
-
|
243
|
-
|
244
|
-
</div>
|
245
|
-
|
246
|
-
|
247
|
-
</div>
|
248
|
-
|
249
|
-
|
250
|
-
<div id="validator-badges">
|
251
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
252
|
-
</div>
|
253
|
-
|
254
|
-
</body>
|
255
|
-
</html>
|