cachetastic 2.1.4 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,643 +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::Caches::Base</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::Caches::Base</td>
|
54
|
-
</tr>
|
55
|
-
<tr class="top-aligned-row">
|
56
|
-
<td><strong>In:</strong></td>
|
57
|
-
<td>
|
58
|
-
<a href="../../../files/lib/cachetastic/caches/base_rb.html">
|
59
|
-
lib/cachetastic/caches/base.rb
|
60
|
-
</a>
|
61
|
-
<br />
|
62
|
-
</td>
|
63
|
-
</tr>
|
64
|
-
|
65
|
-
<tr class="top-aligned-row">
|
66
|
-
<td><strong>Parent:</strong></td>
|
67
|
-
<td>
|
68
|
-
<a href="../../Object.html">
|
69
|
-
Object
|
70
|
-
</a>
|
71
|
-
</td>
|
72
|
-
</tr>
|
73
|
-
</table>
|
74
|
-
</div>
|
75
|
-
<!-- banner header -->
|
76
|
-
|
77
|
-
<div id="bodyContent">
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
<div id="contextContent">
|
82
|
-
|
83
|
-
<div id="description">
|
84
|
-
<p>
|
85
|
-
When creating a new ‘Cache’ this class should be extended. Once
|
86
|
-
extended you‘ll only need to override just the methods that are
|
87
|
-
different for your cache.
|
88
|
-
</p>
|
89
|
-
<pre>
|
90
|
-
class MyAwesomeCache < Cachetastic::Caches::Base
|
91
|
-
end
|
92
|
-
MyAwesomeCache.set(1, "One")
|
93
|
-
MyAwesomeCache.get(1) # => "One"
|
94
|
-
MyAwesomeCache.update(1, "One!!")
|
95
|
-
MyAwesomeCache.get(1) # => "One!!"
|
96
|
-
MyAwesomeCache.delete(1)
|
97
|
-
MyAwesomeCache.get(1) # => nil
|
98
|
-
|
99
|
-
class MyAwesomeCache < Cachetastic::Caches::Base
|
100
|
-
class << self
|
101
|
-
def get(key)
|
102
|
-
super(key) do
|
103
|
-
set(key, key * 10)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
MyAwesomeCache.set(1, "One")
|
109
|
-
MyAwesomeCache.get(1) # => "One"
|
110
|
-
MyAwesomeCache.delete(1)
|
111
|
-
MyAwesomeCache.get(1) # => 10
|
112
|
-
</pre>
|
113
|
-
|
114
|
-
</div>
|
115
|
-
|
116
|
-
|
117
|
-
</div>
|
118
|
-
|
119
|
-
<div id="method-list">
|
120
|
-
<h3 class="section-bar">Methods</h3>
|
121
|
-
|
122
|
-
<div class="name-list">
|
123
|
-
<a href="#M000058">adapter</a>
|
124
|
-
<a href="#M000061">adapter_supported?</a>
|
125
|
-
<a href="#M000051">all_registered_caches</a>
|
126
|
-
<a href="#M000057">cache_name</a>
|
127
|
-
<a href="#M000064">calculate_expiry_time</a>
|
128
|
-
<a href="#M000054">delete</a>
|
129
|
-
<a href="#M000055">expire_all</a>
|
130
|
-
<a href="#M000052">get</a>
|
131
|
-
<a href="#M000059">logger</a>
|
132
|
-
<a href="#M000062">marshall</a>
|
133
|
-
<a href="#M000053">set</a>
|
134
|
-
<a href="#M000056">stats</a>
|
135
|
-
<a href="#M000063">unmarshall</a>
|
136
|
-
<a href="#M000060">unsupported_adapters</a>
|
137
|
-
</div>
|
138
|
-
</div>
|
139
|
-
|
140
|
-
</div>
|
141
|
-
|
142
|
-
|
143
|
-
<!-- if includes -->
|
144
|
-
|
145
|
-
<div id="section">
|
146
|
-
|
147
|
-
<div id="class-list">
|
148
|
-
<h3 class="section-bar">Classes and Modules</h3>
|
149
|
-
|
150
|
-
Class <a href="Base/RegisteredCaches.html" class="link">Cachetastic::Caches::Base::RegisteredCaches</a><br />
|
151
|
-
|
152
|
-
</div>
|
153
|
-
|
154
|
-
|
155
|
-
<div id="aliases-list">
|
156
|
-
<h3 class="section-bar">External Aliases</h3>
|
157
|
-
|
158
|
-
<div class="name-list">
|
159
|
-
<table summary="aliases">
|
160
|
-
<tr class="top-aligned-row context-row">
|
161
|
-
<td class="context-item-name">set</td>
|
162
|
-
<td>-></td>
|
163
|
-
<td class="context-item-value">put</td>
|
164
|
-
</tr>
|
165
|
-
</table>
|
166
|
-
</div>
|
167
|
-
</div>
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
<!-- if method_list -->
|
174
|
-
<div id="methods">
|
175
|
-
<h3 class="section-bar">Public Class methods</h3>
|
176
|
-
|
177
|
-
<div id="method-M000058" class="method-detail">
|
178
|
-
<a name="M000058"></a>
|
179
|
-
|
180
|
-
<div class="method-heading">
|
181
|
-
<a href="#M000058" class="method-signature">
|
182
|
-
<span class="method-name">adapter</span><span class="method-args">()</span>
|
183
|
-
</a>
|
184
|
-
</div>
|
185
|
-
|
186
|
-
<div class="method-description">
|
187
|
-
<p>
|
188
|
-
Returns the underlying <a
|
189
|
-
href="../Adapters/Base.html">Cachetastic::Adapters::Base</a> for this
|
190
|
-
cache.
|
191
|
-
</p>
|
192
|
-
<p><a class="source-toggle" href="#"
|
193
|
-
onclick="toggleCode('M000058-source');return false;">[Source]</a></p>
|
194
|
-
<div class="method-source-code" id="M000058-source">
|
195
|
-
<pre>
|
196
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/caches/base.rb, line 139</span>
|
197
|
-
139: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">adapter</span>
|
198
|
-
140: <span class="ruby-identifier">a</span> = <span class="ruby-identifier">cache_conn_instance</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">cache_name</span>)
|
199
|
-
141: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">adapter_supported?</span>(<span class="ruby-identifier">a</span>.<span class="ruby-identifier">class</span>)
|
200
|
-
142: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">a</span>
|
201
|
-
143: <span class="ruby-keyword kw">else</span>
|
202
|
-
144: <span class="ruby-identifier">raise</span> <span class="ruby-constant">Cachetastic</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span><span class="ruby-operator">::</span><span class="ruby-constant">UnsupportedAdapter</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">cache_name</span>, <span class="ruby-identifier">a</span>.<span class="ruby-identifier">class</span>)
|
203
|
-
145: <span class="ruby-keyword kw">end</span>
|
204
|
-
146: <span class="ruby-keyword kw">end</span>
|
205
|
-
</pre>
|
206
|
-
</div>
|
207
|
-
</div>
|
208
|
-
</div>
|
209
|
-
|
210
|
-
<div id="method-M000061" class="method-detail">
|
211
|
-
<a name="M000061"></a>
|
212
|
-
|
213
|
-
<div class="method-heading">
|
214
|
-
<a href="#M000061" class="method-signature">
|
215
|
-
<span class="method-name">adapter_supported?</span><span class="method-args">(a = cache_conn_instance.get(cache_name).class)</span>
|
216
|
-
</a>
|
217
|
-
</div>
|
218
|
-
|
219
|
-
<div class="method-description">
|
220
|
-
<p>
|
221
|
-
Returns true/false on whether the <a href="Base.html#M000058">adapter</a>
|
222
|
-
you want to use is supported for the cache.
|
223
|
-
</p>
|
224
|
-
<p><a class="source-toggle" href="#"
|
225
|
-
onclick="toggleCode('M000061-source');return false;">[Source]</a></p>
|
226
|
-
<div class="method-source-code" id="M000061-source">
|
227
|
-
<pre>
|
228
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/caches/base.rb, line 161</span>
|
229
|
-
161: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">adapter_supported?</span>(<span class="ruby-identifier">a</span> = <span class="ruby-identifier">cache_conn_instance</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">cache_name</span>).<span class="ruby-identifier">class</span>)
|
230
|
-
162: <span class="ruby-keyword kw">return</span> <span class="ruby-operator">!</span><span class="ruby-identifier">unsupported_adapters</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">a</span>)
|
231
|
-
163: <span class="ruby-keyword kw">end</span>
|
232
|
-
</pre>
|
233
|
-
</div>
|
234
|
-
</div>
|
235
|
-
</div>
|
236
|
-
|
237
|
-
<div id="method-M000051" class="method-detail">
|
238
|
-
<a name="M000051"></a>
|
239
|
-
|
240
|
-
<div class="method-heading">
|
241
|
-
<a href="#M000051" class="method-signature">
|
242
|
-
<span class="method-name">all_registered_caches</span><span class="method-args">()</span>
|
243
|
-
</a>
|
244
|
-
</div>
|
245
|
-
|
246
|
-
<div class="method-description">
|
247
|
-
<p>
|
248
|
-
Returns a list of all registered caches in the system.
|
249
|
-
</p>
|
250
|
-
<p><a class="source-toggle" href="#"
|
251
|
-
onclick="toggleCode('M000051-source');return false;">[Source]</a></p>
|
252
|
-
<div class="method-source-code" id="M000051-source">
|
253
|
-
<pre>
|
254
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/caches/base.rb, line 48</span>
|
255
|
-
48: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">all_registered_caches</span>
|
256
|
-
49: <span class="ruby-constant">RegisteredCaches</span>.<span class="ruby-identifier">instance</span>.<span class="ruby-identifier">list</span>
|
257
|
-
50: <span class="ruby-keyword kw">end</span>
|
258
|
-
</pre>
|
259
|
-
</div>
|
260
|
-
</div>
|
261
|
-
</div>
|
262
|
-
|
263
|
-
<div id="method-M000057" class="method-detail">
|
264
|
-
<a name="M000057"></a>
|
265
|
-
|
266
|
-
<div class="method-heading">
|
267
|
-
<a href="#M000057" class="method-signature">
|
268
|
-
<span class="method-name">cache_name</span><span class="method-args">()</span>
|
269
|
-
</a>
|
270
|
-
</div>
|
271
|
-
|
272
|
-
<div class="method-description">
|
273
|
-
<p>
|
274
|
-
Returns a ‘methodize’ version of the cache‘s class name.
|
275
|
-
This gets used in logging, namespacing, and as the key in the <a
|
276
|
-
href="../Connection.html">Cachetastic::Connection</a> class.
|
277
|
-
</p>
|
278
|
-
<pre>
|
279
|
-
MyAwesomeCache.cache # => "my_awesome_cache"
|
280
|
-
Cachetastic::Caches::Base # => "cachetastic_caches_base"
|
281
|
-
</pre>
|
282
|
-
<p><a class="source-toggle" href="#"
|
283
|
-
onclick="toggleCode('M000057-source');return false;">[Source]</a></p>
|
284
|
-
<div class="method-source-code" id="M000057-source">
|
285
|
-
<pre>
|
286
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/caches/base.rb, line 134</span>
|
287
|
-
134: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cache_name</span>
|
288
|
-
135: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">name</span>.<span class="ruby-identifier">methodize</span>
|
289
|
-
136: <span class="ruby-keyword kw">end</span>
|
290
|
-
</pre>
|
291
|
-
</div>
|
292
|
-
</div>
|
293
|
-
</div>
|
294
|
-
|
295
|
-
<div id="method-M000054" class="method-detail">
|
296
|
-
<a name="M000054"></a>
|
297
|
-
|
298
|
-
<div class="method-heading">
|
299
|
-
<a href="#M000054" class="method-signature">
|
300
|
-
<span class="method-name">delete</span><span class="method-args">(key, delay = 0)</span>
|
301
|
-
</a>
|
302
|
-
</div>
|
303
|
-
|
304
|
-
<div class="method-description">
|
305
|
-
<p>
|
306
|
-
Deletes an object from the cache. The optional delay parameter sets an
|
307
|
-
offset, in seconds, for when the object should <a
|
308
|
-
href="Base.html#M000052">get</a> deleted. The default of 0 means the object
|
309
|
-
gets deleted right away.
|
310
|
-
</p>
|
311
|
-
<p><a class="source-toggle" href="#"
|
312
|
-
onclick="toggleCode('M000054-source');return false;">[Source]</a></p>
|
313
|
-
<div class="method-source-code" id="M000054-source">
|
314
|
-
<pre>
|
315
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/caches/base.rb, line 108</span>
|
316
|
-
108: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">delay</span> = <span class="ruby-value">0</span>)
|
317
|
-
109: <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>
|
318
|
-
110: <span class="ruby-identifier">adapter</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">delay</span>)
|
319
|
-
111: <span class="ruby-keyword kw">end</span>
|
320
|
-
112: <span class="ruby-keyword kw">end</span>
|
321
|
-
</pre>
|
322
|
-
</div>
|
323
|
-
</div>
|
324
|
-
</div>
|
325
|
-
|
326
|
-
<div id="method-M000055" class="method-detail">
|
327
|
-
<a name="M000055"></a>
|
328
|
-
|
329
|
-
<div class="method-heading">
|
330
|
-
<a href="#M000055" class="method-signature">
|
331
|
-
<span class="method-name">expire_all</span><span class="method-args">()</span>
|
332
|
-
</a>
|
333
|
-
</div>
|
334
|
-
|
335
|
-
<div class="method-description">
|
336
|
-
<p>
|
337
|
-
Expires all objects for this cache.
|
338
|
-
</p>
|
339
|
-
<p><a class="source-toggle" href="#"
|
340
|
-
onclick="toggleCode('M000055-source');return false;">[Source]</a></p>
|
341
|
-
<div class="method-source-code" id="M000055-source">
|
342
|
-
<pre>
|
343
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/caches/base.rb, line 115</span>
|
344
|
-
115: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">expire_all</span>
|
345
|
-
116: <span class="ruby-identifier">adapter</span>.<span class="ruby-identifier">expire_all</span>
|
346
|
-
117: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span>(<span class="ruby-value str">''</span>, <span class="ruby-value str">''</span>, <span class="ruby-identifier">:expired</span>, <span class="ruby-identifier">cache_name</span>)
|
347
|
-
118: <span class="ruby-keyword kw">end</span>
|
348
|
-
</pre>
|
349
|
-
</div>
|
350
|
-
</div>
|
351
|
-
</div>
|
352
|
-
|
353
|
-
<div id="method-M000052" class="method-detail">
|
354
|
-
<a name="M000052"></a>
|
355
|
-
|
356
|
-
<div class="method-heading">
|
357
|
-
<a href="#M000052" class="method-signature">
|
358
|
-
<span class="method-name">get</span><span class="method-args">(key) {|key if block_given?| ...}</span>
|
359
|
-
</a>
|
360
|
-
</div>
|
361
|
-
|
362
|
-
<div class="method-description">
|
363
|
-
<p>
|
364
|
-
Returns an object from the cache for a given key. If the object comes back
|
365
|
-
as nil and a block is given that block will be run and the results of the
|
366
|
-
block will be run. This can be used to JIT caches, just make sure in the
|
367
|
-
block to call the <a href="Base.html#M000053">set</a> method because the
|
368
|
-
results of the block are not automatically cached.
|
369
|
-
</p>
|
370
|
-
<p><a class="source-toggle" href="#"
|
371
|
-
onclick="toggleCode('M000052-source');return false;">[Source]</a></p>
|
372
|
-
<div class="method-source-code" id="M000052-source">
|
373
|
-
<pre>
|
374
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/caches/base.rb, line 58</span>
|
375
|
-
58: <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>)
|
376
|
-
59: <span class="ruby-identifier">res</span> = <span class="ruby-keyword kw">nil</span>
|
377
|
-
60: <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>
|
378
|
-
61: <span class="ruby-identifier">retryable</span>(<span class="ruby-identifier">:on</span> =<span class="ruby-operator">></span> <span class="ruby-constant">ArgumentError</span>) <span class="ruby-keyword kw">do</span>
|
379
|
-
62: <span class="ruby-keyword kw">begin</span>
|
380
|
-
63: <span class="ruby-identifier">res</span> = <span class="ruby-identifier">adapter</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>)
|
381
|
-
64: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">res</span>.<span class="ruby-identifier">nil?</span>
|
382
|
-
65: <span class="ruby-identifier">res</span> = <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">key</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
383
|
-
66: <span class="ruby-keyword kw">else</span>
|
384
|
-
67: <span class="ruby-identifier">res</span> = <span class="ruby-identifier">unmarshall</span>(<span class="ruby-identifier">res</span>)
|
385
|
-
68: <span class="ruby-keyword kw">end</span>
|
386
|
-
69: <span class="ruby-identifier">res</span>
|
387
|
-
70: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">ArgumentError</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
388
|
-
71: <span class="ruby-identifier">m</span> = <span class="ruby-identifier">e</span>.<span class="ruby-identifier">message</span>.<span class="ruby-identifier">match</span>(<span class="ruby-regexp re">/class\/module .*/</span>)
|
389
|
-
72: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">m</span>
|
390
|
-
73: <span class="ruby-identifier">m</span> = <span class="ruby-identifier">m</span>.<span class="ruby-identifier">to_s</span>
|
391
|
-
74: <span class="ruby-identifier">m</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-value str">"class/module"</span>, <span class="ruby-value str">''</span>)
|
392
|
-
75: <span class="ruby-identifier">m</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-value str">"(ArgumentError)"</span>, <span class="ruby-value str">''</span>)
|
393
|
-
76: <span class="ruby-identifier">require</span> <span class="ruby-identifier">m</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">underscore</span>
|
394
|
-
77: <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>
|
395
|
-
78: <span class="ruby-keyword kw">end</span>
|
396
|
-
79: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
397
|
-
80: <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>
|
398
|
-
81: <span class="ruby-keyword kw">end</span>
|
399
|
-
82: <span class="ruby-keyword kw">end</span>
|
400
|
-
83: <span class="ruby-keyword kw">end</span>
|
401
|
-
84: <span class="ruby-identifier">res</span>
|
402
|
-
85: <span class="ruby-keyword kw">end</span>
|
403
|
-
</pre>
|
404
|
-
</div>
|
405
|
-
</div>
|
406
|
-
</div>
|
407
|
-
|
408
|
-
<div id="method-M000059" class="method-detail">
|
409
|
-
<a name="M000059"></a>
|
410
|
-
|
411
|
-
<div class="method-heading">
|
412
|
-
<a href="#M000059" class="method-signature">
|
413
|
-
<span class="method-name">logger</span><span class="method-args">()</span>
|
414
|
-
</a>
|
415
|
-
</div>
|
416
|
-
|
417
|
-
<div class="method-description">
|
418
|
-
<p>
|
419
|
-
Returns the <a href="../Logger.html">Cachetastic::Logger</a> for the
|
420
|
-
underlying <a href="../Adapters/Base.html">Cachetastic::Adapters::Base</a>.
|
421
|
-
</p>
|
422
|
-
<p><a class="source-toggle" href="#"
|
423
|
-
onclick="toggleCode('M000059-source');return false;">[Source]</a></p>
|
424
|
-
<div class="method-source-code" id="M000059-source">
|
425
|
-
<pre>
|
426
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/caches/base.rb, line 149</span>
|
427
|
-
149: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">logger</span>
|
428
|
-
150: <span class="ruby-identifier">adapter</span>.<span class="ruby-identifier">logger</span>
|
429
|
-
151: <span class="ruby-keyword kw">end</span>
|
430
|
-
</pre>
|
431
|
-
</div>
|
432
|
-
</div>
|
433
|
-
</div>
|
434
|
-
|
435
|
-
<div id="method-M000062" class="method-detail">
|
436
|
-
<a name="M000062"></a>
|
437
|
-
|
438
|
-
<div class="method-heading">
|
439
|
-
<a href="#M000062" class="method-signature">
|
440
|
-
<span class="method-name">marshall</span><span class="method-args">(value)</span>
|
441
|
-
</a>
|
442
|
-
</div>
|
443
|
-
|
444
|
-
<div class="method-description">
|
445
|
-
<p><a class="source-toggle" href="#"
|
446
|
-
onclick="toggleCode('M000062-source');return false;">[Source]</a></p>
|
447
|
-
<div class="method-source-code" id="M000062-source">
|
448
|
-
<pre>
|
449
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/caches/base.rb, line 165</span>
|
450
|
-
165: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">marshall</span>(<span class="ruby-identifier">value</span>)
|
451
|
-
166: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">value</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">nil?</span>
|
452
|
-
167: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">adapter</span>.<span class="ruby-identifier">configuration</span>.<span class="ruby-identifier">retrieve</span>(<span class="ruby-identifier">:marshall_method</span>, <span class="ruby-identifier">:none</span>).<span class="ruby-identifier">to_sym</span>
|
453
|
-
168: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:yaml</span>
|
454
|
-
169: <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">dump</span>(<span class="ruby-identifier">value</span>)
|
455
|
-
170: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:ruby</span>
|
456
|
-
171: <span class="ruby-constant">Marshal</span>.<span class="ruby-identifier">dump</span>(<span class="ruby-identifier">value</span>)
|
457
|
-
172: <span class="ruby-keyword kw">else</span>
|
458
|
-
173: <span class="ruby-identifier">value</span>
|
459
|
-
174: <span class="ruby-keyword kw">end</span>
|
460
|
-
175: <span class="ruby-keyword kw">end</span>
|
461
|
-
</pre>
|
462
|
-
</div>
|
463
|
-
</div>
|
464
|
-
</div>
|
465
|
-
|
466
|
-
<div id="method-M000053" class="method-detail">
|
467
|
-
<a name="M000053"></a>
|
468
|
-
|
469
|
-
<div class="method-heading">
|
470
|
-
<a href="#M000053" class="method-signature">
|
471
|
-
<span class="method-name">set</span><span class="method-args">(key, value, expiry = adapter.configuration.retrieve(:default_expiry, 0))</span>
|
472
|
-
</a>
|
473
|
-
</div>
|
474
|
-
|
475
|
-
<div class="method-description">
|
476
|
-
<p>
|
477
|
-
Set a particular object info the cache for the given key. An optional third
|
478
|
-
parameter sets the expiry time for the object in the cache. The default for
|
479
|
-
this expiry is <a href="Base.html#M000053">set</a> as either 0, meaning it
|
480
|
-
never expires, or if there‘s a default_expiry time <a
|
481
|
-
href="Base.html#M000053">set</a> in the config file, that file will be
|
482
|
-
used. If there is an expiry_swing <a href="Base.html#M000053">set</a> in
|
483
|
-
the config file it will be +/- to the expiry time. See also: <a
|
484
|
-
href="Base.html#M000064">calculate_expiry_time</a>
|
485
|
-
</p>
|
486
|
-
<p><a class="source-toggle" href="#"
|
487
|
-
onclick="toggleCode('M000053-source');return false;">[Source]</a></p>
|
488
|
-
<div class="method-source-code" id="M000053-source">
|
489
|
-
<pre>
|
490
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/caches/base.rb, line 94</span>
|
491
|
-
94: <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</span> = <span class="ruby-identifier">adapter</span>.<span class="ruby-identifier">configuration</span>.<span class="ruby-identifier">retrieve</span>(<span class="ruby-identifier">:default_expiry</span>, <span class="ruby-value">0</span>))
|
492
|
-
95: <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>
|
493
|
-
96: <span class="ruby-identifier">expiry</span> = <span class="ruby-identifier">calculate_expiry_time</span>(<span class="ruby-identifier">expiry</span>)
|
494
|
-
97: <span class="ruby-identifier">adapter</span>.<span class="ruby-identifier">set</span>(<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">marshall</span>(<span class="ruby-identifier">value</span>), <span class="ruby-identifier">expiry</span>.<span class="ruby-identifier">to_i</span>)
|
495
|
-
98: <span class="ruby-identifier">logger</span>.<span class="ruby-identifier">info</span>(<span class="ruby-value str">''</span>, <span class="ruby-value str">''</span>, <span class="ruby-identifier">:expiry</span>, <span class="ruby-identifier">cache_name</span>, <span class="ruby-identifier">key</span>, <span class="ruby-identifier">expiry</span>.<span class="ruby-identifier">to_i</span>)
|
496
|
-
99: <span class="ruby-identifier">value</span>
|
497
|
-
100: <span class="ruby-keyword kw">end</span>
|
498
|
-
101: <span class="ruby-keyword kw">end</span>
|
499
|
-
</pre>
|
500
|
-
</div>
|
501
|
-
</div>
|
502
|
-
</div>
|
503
|
-
|
504
|
-
<div id="method-M000056" class="method-detail">
|
505
|
-
<a name="M000056"></a>
|
506
|
-
|
507
|
-
<div class="method-heading">
|
508
|
-
<a href="#M000056" class="method-signature">
|
509
|
-
<span class="method-name">stats</span><span class="method-args">()</span>
|
510
|
-
</a>
|
511
|
-
</div>
|
512
|
-
|
513
|
-
<div class="method-description">
|
514
|
-
<p>
|
515
|
-
A convenience method that returns statistics for the underlying <a
|
516
|
-
href="../Adapters/Base.html">Cachetastic::Adapters::Base</a> for the cache.
|
517
|
-
</p>
|
518
|
-
<p><a class="source-toggle" href="#"
|
519
|
-
onclick="toggleCode('M000056-source');return false;">[Source]</a></p>
|
520
|
-
<div class="method-source-code" id="M000056-source">
|
521
|
-
<pre>
|
522
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/caches/base.rb, line 126</span>
|
523
|
-
126: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stats</span>
|
524
|
-
127: <span class="ruby-identifier">adapter</span>.<span class="ruby-identifier">stats</span>
|
525
|
-
128: <span class="ruby-keyword kw">end</span>
|
526
|
-
</pre>
|
527
|
-
</div>
|
528
|
-
</div>
|
529
|
-
</div>
|
530
|
-
|
531
|
-
<div id="method-M000063" class="method-detail">
|
532
|
-
<a name="M000063"></a>
|
533
|
-
|
534
|
-
<div class="method-heading">
|
535
|
-
<a href="#M000063" class="method-signature">
|
536
|
-
<span class="method-name">unmarshall</span><span class="method-args">(value)</span>
|
537
|
-
</a>
|
538
|
-
</div>
|
539
|
-
|
540
|
-
<div class="method-description">
|
541
|
-
<p><a class="source-toggle" href="#"
|
542
|
-
onclick="toggleCode('M000063-source');return false;">[Source]</a></p>
|
543
|
-
<div class="method-source-code" id="M000063-source">
|
544
|
-
<pre>
|
545
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/caches/base.rb, line 177</span>
|
546
|
-
177: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unmarshall</span>(<span class="ruby-identifier">value</span>)
|
547
|
-
178: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">value</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">nil?</span>
|
548
|
-
179: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">adapter</span>.<span class="ruby-identifier">configuration</span>.<span class="ruby-identifier">retrieve</span>(<span class="ruby-identifier">:marshall_method</span>, <span class="ruby-identifier">:none</span>).<span class="ruby-identifier">to_sym</span>
|
549
|
-
180: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:yaml</span>
|
550
|
-
181: <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">load</span>(<span class="ruby-identifier">value</span>)
|
551
|
-
182: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:ruby</span>
|
552
|
-
183: <span class="ruby-constant">Marshal</span>.<span class="ruby-identifier">load</span>(<span class="ruby-identifier">value</span>)
|
553
|
-
184: <span class="ruby-keyword kw">else</span>
|
554
|
-
185: <span class="ruby-identifier">value</span>
|
555
|
-
186: <span class="ruby-keyword kw">end</span>
|
556
|
-
187: <span class="ruby-keyword kw">end</span>
|
557
|
-
</pre>
|
558
|
-
</div>
|
559
|
-
</div>
|
560
|
-
</div>
|
561
|
-
|
562
|
-
<div id="method-M000060" class="method-detail">
|
563
|
-
<a name="M000060"></a>
|
564
|
-
|
565
|
-
<div class="method-heading">
|
566
|
-
<a href="#M000060" class="method-signature">
|
567
|
-
<span class="method-name">unsupported_adapters</span><span class="method-args">()</span>
|
568
|
-
</a>
|
569
|
-
</div>
|
570
|
-
|
571
|
-
<div class="method-description">
|
572
|
-
<p>
|
573
|
-
Returns an array of unsupported adapters for this cache. Defaults to an
|
574
|
-
empty array which will let any <a href="Base.html#M000058">adapter</a> be
|
575
|
-
used by the cache. Override in your specific cache to prevent certain
|
576
|
-
adapters.
|
577
|
-
</p>
|
578
|
-
<p><a class="source-toggle" href="#"
|
579
|
-
onclick="toggleCode('M000060-source');return false;">[Source]</a></p>
|
580
|
-
<div class="method-source-code" id="M000060-source">
|
581
|
-
<pre>
|
582
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/caches/base.rb, line 156</span>
|
583
|
-
156: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">unsupported_adapters</span>
|
584
|
-
157: []
|
585
|
-
158: <span class="ruby-keyword kw">end</span>
|
586
|
-
</pre>
|
587
|
-
</div>
|
588
|
-
</div>
|
589
|
-
</div>
|
590
|
-
|
591
|
-
<h3 class="section-bar">Private Class methods</h3>
|
592
|
-
|
593
|
-
<div id="method-M000064" class="method-detail">
|
594
|
-
<a name="M000064"></a>
|
595
|
-
|
596
|
-
<div class="method-heading">
|
597
|
-
<a href="#M000064" class="method-signature">
|
598
|
-
<span class="method-name">calculate_expiry_time</span><span class="method-args">(expiry)</span>
|
599
|
-
</a>
|
600
|
-
</div>
|
601
|
-
|
602
|
-
<div class="method-description">
|
603
|
-
<p>
|
604
|
-
If the expiry time is <a href="Base.html#M000053">set</a> to 60 minutes and
|
605
|
-
the expiry_swing time is <a href="Base.html#M000053">set</a> to 15 minutes,
|
606
|
-
this method will return a number between 45 minutes and 75 minutes.
|
607
|
-
</p>
|
608
|
-
<p><a class="source-toggle" href="#"
|
609
|
-
onclick="toggleCode('M000064-source');return false;">[Source]</a></p>
|
610
|
-
<div class="method-source-code" id="M000064-source">
|
611
|
-
<pre>
|
612
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/caches/base.rb, line 192</span>
|
613
|
-
192: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">calculate_expiry_time</span>(<span class="ruby-identifier">expiry</span>) <span class="ruby-comment cmt"># :doc:</span>
|
614
|
-
193: <span class="ruby-identifier">exp_swing</span> = <span class="ruby-identifier">adapter</span>.<span class="ruby-identifier">configuration</span>.<span class="ruby-identifier">retrieve</span>(<span class="ruby-identifier">:expiry_swing</span>, <span class="ruby-value">0</span>)
|
615
|
-
194: <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>
|
616
|
-
195: <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>)
|
617
|
-
196: <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">rand</span>(<span class="ruby-value">2</span>)
|
618
|
-
197: <span class="ruby-keyword kw">when</span> <span class="ruby-value">0</span>
|
619
|
-
198: <span class="ruby-identifier">expiry</span> = (<span class="ruby-identifier">expiry</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">swing</span>)
|
620
|
-
199: <span class="ruby-keyword kw">when</span> <span class="ruby-value">1</span>
|
621
|
-
200: <span class="ruby-identifier">expiry</span> = (<span class="ruby-identifier">expiry</span>.<span class="ruby-identifier">to_i</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">swing</span>)
|
622
|
-
201: <span class="ruby-keyword kw">end</span>
|
623
|
-
202: <span class="ruby-keyword kw">end</span>
|
624
|
-
203: <span class="ruby-identifier">expiry</span>
|
625
|
-
204: <span class="ruby-keyword kw">end</span>
|
626
|
-
</pre>
|
627
|
-
</div>
|
628
|
-
</div>
|
629
|
-
</div>
|
630
|
-
|
631
|
-
|
632
|
-
</div>
|
633
|
-
|
634
|
-
|
635
|
-
</div>
|
636
|
-
|
637
|
-
|
638
|
-
<div id="validator-badges">
|
639
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
640
|
-
</div>
|
641
|
-
|
642
|
-
</body>
|
643
|
-
</html>
|