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