cachetastic 2.1.4 → 3.0.0
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/LICENSE +21 -0
- data/README +57 -43
- data/doc/classes/Cachetastic/Adapters.html +180 -0
- data/doc/classes/Cachetastic/Adapters/Base.html +206 -123
- data/doc/classes/Cachetastic/Adapters/File.html +17 -130
- data/doc/classes/Cachetastic/Adapters/LocalMemory.html +7 -228
- data/doc/classes/Cachetastic/Adapters/Memcached.html +193 -0
- data/doc/classes/Cachetastic/Cache.html +425 -0
- data/doc/classes/Cachetastic/Cacheable.html +26 -30
- data/doc/classes/Cachetastic/Cacheable/ClassAndInstanceMethods.html +66 -62
- data/doc/classes/Cachetastic/Cacheable/ClassOnlyMethods.html +30 -30
- data/doc/classes/Cachetastic/Logger.html +31 -33
- data/doc/created.rid +1 -1
- data/doc/files/{lib/cachetastic/adapters/html_file_rb.html → LICENSE.html} +29 -34
- data/doc/files/README.html +91 -57
- data/doc/files/lib/cachetastic/adapters/base_rb.html +1 -39
- data/doc/files/lib/cachetastic/adapters/file_rb.html +1 -21
- data/doc/files/lib/cachetastic/adapters/local_memory_rb.html +1 -9
- data/doc/files/lib/cachetastic/{ruby_extensions/kernel_rb.html → adapters/memcached_rb.html} +4 -4
- data/doc/files/lib/cachetastic/{ruby_extensions/string_rb.html → cache_rb.html} +5 -5
- data/doc/files/lib/cachetastic/cacheable_rb.html +1 -1
- data/doc/files/lib/cachetastic/{caches/base_rb.html → extensions/string_rb.html} +5 -5
- data/doc/files/lib/cachetastic/logger_rb.html +1 -7
- data/doc/files/lib/cachetastic/{adapters/store_object_rb.html → store_object_rb.html} +3 -3
- data/doc/files/lib/cachetastic_rb.html +4 -95
- data/doc/fr_class_index.html +3 -15
- data/doc/fr_file_index.html +5 -16
- data/doc/fr_method_index.html +26 -78
- data/lib/cachetastic.rb +16 -70
- data/lib/cachetastic/adapters/base.rb +178 -76
- data/lib/cachetastic/adapters/file.rb +63 -46
- data/lib/cachetastic/adapters/local_memory.rb +36 -67
- data/lib/cachetastic/adapters/memcached.rb +114 -0
- data/lib/cachetastic/cache.rb +165 -0
- data/lib/cachetastic/cacheable.rb +19 -15
- data/lib/cachetastic/extensions/string.rb +8 -0
- data/lib/cachetastic/logger.rb +41 -41
- data/lib/cachetastic/store_object.rb +22 -0
- metadata +43 -64
- data/bin/cachetastic_drb_server +0 -115
- data/doc/classes/ActiveRecord/Base.html +0 -194
- data/doc/classes/CGI/Session/CachetasticStore.html +0 -124
- data/doc/classes/Cachetastic/Adapters/Drb.html +0 -332
- data/doc/classes/Cachetastic/Adapters/FileBase.html +0 -309
- data/doc/classes/Cachetastic/Adapters/HtmlFile.html +0 -224
- data/doc/classes/Cachetastic/Adapters/Memcache.html +0 -498
- data/doc/classes/Cachetastic/Caches/Base.html +0 -643
- data/doc/classes/Cachetastic/Caches/Base/RegisteredCaches.html +0 -179
- data/doc/classes/Cachetastic/Caches/MackSessionCache.html +0 -119
- data/doc/classes/Cachetastic/Caches/PageCache.html +0 -121
- data/doc/classes/Cachetastic/Caches/RailsSessionCache.html +0 -154
- data/doc/classes/Cachetastic/Connection.html +0 -212
- data/doc/classes/Cachetastic/Errors/UnsupportedAdapter.html +0 -146
- data/doc/classes/Object.html +0 -222
- data/doc/classes/String.html +0 -172
- data/doc/files/lib/cachetastic/adapters/drb_rb.html +0 -115
- data/doc/files/lib/cachetastic/adapters/file_base_rb.html +0 -109
- data/doc/files/lib/cachetastic/adapters/memcache_rb.html +0 -127
- data/doc/files/lib/cachetastic/caches/mack_session_cache_rb.html +0 -107
- data/doc/files/lib/cachetastic/caches/page_cache_rb.html +0 -109
- data/doc/files/lib/cachetastic/caches/rails_session_cache_rb.html +0 -107
- data/doc/files/lib/cachetastic/connection_rb.html +0 -107
- data/doc/files/lib/cachetastic/errors/unsupported_adapter_rb.html +0 -101
- data/doc/files/lib/cachetastic/rails_extensions/active_record_base_rb.html +0 -101
- data/doc/files/lib/cachetastic/rails_extensions/cgi_session_store_rb.html +0 -109
- data/doc/files/lib/cachetastic/ruby_extensions/object_rb.html +0 -101
- data/lib/cachetastic/adapters/drb.rb +0 -51
- data/lib/cachetastic/adapters/file_base.rb +0 -86
- data/lib/cachetastic/adapters/html_file.rb +0 -68
- data/lib/cachetastic/adapters/memcache.rb +0 -114
- data/lib/cachetastic/adapters/store_object.rb +0 -28
- data/lib/cachetastic/caches/base.rb +0 -238
- data/lib/cachetastic/caches/mack_session_cache.rb +0 -3
- data/lib/cachetastic/caches/page_cache.rb +0 -6
- data/lib/cachetastic/caches/rails_session_cache.rb +0 -12
- data/lib/cachetastic/connection.rb +0 -24
- data/lib/cachetastic/errors/unsupported_adapter.rb +0 -7
- data/lib/cachetastic/rails_extensions/active_record_base.rb +0 -24
- data/lib/cachetastic/rails_extensions/cgi_session_store.rb +0 -59
- data/lib/cachetastic/ruby_extensions/kernel.rb +0 -25
- data/lib/cachetastic/ruby_extensions/object.rb +0 -22
- data/lib/cachetastic/ruby_extensions/string.rb +0 -15
- data/test/active_record_test.rb +0 -89
- data/test/cacheable_test.rb +0 -88
- data/test/cachetastic_unit_test.rb +0 -74
- data/test/config.rb +0 -30
- data/test/drb_adapter_test.rb +0 -14
- data/test/file_adapter_test.rb +0 -49
- data/test/memcache_adapter_test.rb +0 -18
- data/test/test_helper.rb +0 -75
|
@@ -0,0 +1,425 @@
|
|
|
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>
|
|
@@ -58,10 +58,6 @@
|
|
|
58
58
|
<a href="../../files/lib/cachetastic/cacheable_rb.html">
|
|
59
59
|
lib/cachetastic/cacheable.rb
|
|
60
60
|
</a>
|
|
61
|
-
<br />
|
|
62
|
-
<a href="../../files/lib/cachetastic_rb.html">
|
|
63
|
-
lib/cachetastic.rb
|
|
64
|
-
</a>
|
|
65
61
|
<br />
|
|
66
62
|
</td>
|
|
67
63
|
</tr>
|
|
@@ -78,8 +74,8 @@
|
|
|
78
74
|
|
|
79
75
|
<div id="description">
|
|
80
76
|
<p>
|
|
81
|
-
Include this module into an
|
|
82
|
-
|
|
77
|
+
Include this module into an Object to achieve simplistic Object level
|
|
78
|
+
caching.
|
|
83
79
|
</p>
|
|
84
80
|
<p>
|
|
85
81
|
Example:
|
|
@@ -112,8 +108,8 @@ Example:
|
|
|
112
108
|
<h3 class="section-bar">Methods</h3>
|
|
113
109
|
|
|
114
110
|
<div class="name-list">
|
|
115
|
-
<a href="#
|
|
116
|
-
<a href="#
|
|
111
|
+
<a href="#M000010">cache_self</a>
|
|
112
|
+
<a href="#M000011">uncache_self</a>
|
|
117
113
|
</div>
|
|
118
114
|
</div>
|
|
119
115
|
|
|
@@ -142,11 +138,11 @@ Module <a href="Cacheable/ClassOnlyMethods.html" class="link">Cachetastic::Cache
|
|
|
142
138
|
<div id="methods">
|
|
143
139
|
<h3 class="section-bar">Public Instance methods</h3>
|
|
144
140
|
|
|
145
|
-
<div id="method-
|
|
146
|
-
<a name="
|
|
141
|
+
<div id="method-M000010" class="method-detail">
|
|
142
|
+
<a name="M000010"></a>
|
|
147
143
|
|
|
148
144
|
<div class="method-heading">
|
|
149
|
-
<a href="#
|
|
145
|
+
<a href="#M000010" class="method-signature">
|
|
150
146
|
<span class="method-name">cache_self</span><span class="method-args">()</span>
|
|
151
147
|
</a>
|
|
152
148
|
</div>
|
|
@@ -158,8 +154,8 @@ will store the object in the cache using the object‘s cachetastic_key
|
|
|
158
154
|
as the key. You <b>MUST</b> create an instance level method called
|
|
159
155
|
cachetastic_key and have it return a valid key! If you return nil from the
|
|
160
156
|
cachetastic_key method or you will not be able to use the <a
|
|
161
|
-
href="Cacheable.html#
|
|
162
|
-
href="Cacheable.html#
|
|
157
|
+
href="Cacheable.html#M000010">cache_self</a> and <a
|
|
158
|
+
href="Cacheable.html#M000011">uncache_self</a> methods.
|
|
163
159
|
</p>
|
|
164
160
|
<p>
|
|
165
161
|
Example:
|
|
@@ -180,23 +176,23 @@ Example:
|
|
|
180
176
|
Person.get_from_cache("Mark Bates") # => "Mark Bates"
|
|
181
177
|
</pre>
|
|
182
178
|
<p><a class="source-toggle" href="#"
|
|
183
|
-
onclick="toggleCode('
|
|
184
|
-
<div class="method-source-code" id="
|
|
179
|
+
onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
|
|
180
|
+
<div class="method-source-code" id="M000010-source">
|
|
185
181
|
<pre>
|
|
186
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/cacheable.rb, line
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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>
|
|
190
186
|
</pre>
|
|
191
187
|
</div>
|
|
192
188
|
</div>
|
|
193
189
|
</div>
|
|
194
190
|
|
|
195
|
-
<div id="method-
|
|
196
|
-
<a name="
|
|
191
|
+
<div id="method-M000011" class="method-detail">
|
|
192
|
+
<a name="M000011"></a>
|
|
197
193
|
|
|
198
194
|
<div class="method-heading">
|
|
199
|
-
<a href="#
|
|
195
|
+
<a href="#M000011" class="method-signature">
|
|
200
196
|
<span class="method-name">uncache_self</span><span class="method-args">()</span>
|
|
201
197
|
</a>
|
|
202
198
|
</div>
|
|
@@ -208,8 +204,8 @@ will delete the object in the cache using the object‘s
|
|
|
208
204
|
cachetastic_key as the key. You <b>MUST</b> create an instance level method
|
|
209
205
|
called cachetastic_key and have it return a valid key! If you return nil
|
|
210
206
|
from the cachetastic_key method or you will not be able to use the <a
|
|
211
|
-
href="Cacheable.html#
|
|
212
|
-
href="Cacheable.html#
|
|
207
|
+
href="Cacheable.html#M000010">cache_self</a> and <a
|
|
208
|
+
href="Cacheable.html#M000011">uncache_self</a> methods.
|
|
213
209
|
</p>
|
|
214
210
|
<p>
|
|
215
211
|
Example:
|
|
@@ -232,13 +228,13 @@ Example:
|
|
|
232
228
|
Person.get_from_cache("Mark Bates") # => nil
|
|
233
229
|
</pre>
|
|
234
230
|
<p><a class="source-toggle" href="#"
|
|
235
|
-
onclick="toggleCode('
|
|
236
|
-
<div class="method-source-code" id="
|
|
231
|
+
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
|
|
232
|
+
<div class="method-source-code" id="M000011-source">
|
|
237
233
|
<pre>
|
|
238
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/cacheable.rb, line
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
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>
|
|
242
238
|
</pre>
|
|
243
239
|
</div>
|
|
244
240
|
</div>
|