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
@@ -65,8 +65,8 @@
|
|
65
65
|
<tr class="top-aligned-row">
|
66
66
|
<td><strong>Parent:</strong></td>
|
67
67
|
<td>
|
68
|
-
<a href="
|
69
|
-
Cachetastic::Adapters::
|
68
|
+
<a href="Base.html">
|
69
|
+
Cachetastic::Adapters::Base
|
70
70
|
</a>
|
71
71
|
</td>
|
72
72
|
</tr>
|
@@ -82,37 +82,30 @@
|
|
82
82
|
|
83
83
|
<div id="description">
|
84
84
|
<p>
|
85
|
-
|
86
|
-
|
85
|
+
An adapter to cache objects to the file system.
|
86
|
+
</p>
|
87
|
+
<p>
|
88
|
+
This adapter supports the following configuration settings, in addition to
|
89
|
+
the default settings:
|
87
90
|
</p>
|
88
91
|
<pre>
|
89
|
-
|
90
|
-
|
91
|
-
adapter: file
|
92
|
-
marshall_method: none
|
93
|
-
default_expiry: <%= 24.hours %>
|
94
|
-
store_options:
|
95
|
-
dir: /usr/local/caches/
|
96
|
-
logging:
|
97
|
-
logger_1:
|
98
|
-
type: file
|
99
|
-
file: log/file_store_cache.log
|
92
|
+
configatron.cachetastic.defaults.storage_path = ::File.join(FileUtils.pwd, 'cachetastic')
|
93
|
+
configatron.cachetastic.defaults.marshal_method = :yaml
|
100
94
|
</pre>
|
95
|
+
<p>
|
96
|
+
The <tt>storage_path</tt> setting defines the path to where cached objects
|
97
|
+
are written to on disk.
|
98
|
+
</p>
|
99
|
+
<p>
|
100
|
+
See <tt><a href="Base.html">Cachetastic::Adapters::Base</a></tt> for a list
|
101
|
+
of public API methods.
|
102
|
+
</p>
|
101
103
|
|
102
104
|
</div>
|
103
105
|
|
104
106
|
|
105
107
|
</div>
|
106
108
|
|
107
|
-
<div id="method-list">
|
108
|
-
<h3 class="section-bar">Methods</h3>
|
109
|
-
|
110
|
-
<div class="name-list">
|
111
|
-
<a href="#M000047">get</a>
|
112
|
-
<a href="#M000048">set</a>
|
113
|
-
<a href="#M000049">store_file_name</a>
|
114
|
-
</div>
|
115
|
-
</div>
|
116
109
|
|
117
110
|
</div>
|
118
111
|
|
@@ -122,19 +115,6 @@ for this should look something like this:
|
|
122
115
|
<div id="section">
|
123
116
|
|
124
117
|
|
125
|
-
<div id="constants-list">
|
126
|
-
<h3 class="section-bar">Constants</h3>
|
127
|
-
|
128
|
-
<div class="name-list">
|
129
|
-
<table summary="Constants">
|
130
|
-
<tr class="top-aligned-row context-row">
|
131
|
-
<td class="context-item-name">STORE_FILE_NAME</td>
|
132
|
-
<td>=</td>
|
133
|
-
<td class="context-item-value">"cache.yml"</td>
|
134
|
-
</tr>
|
135
|
-
</table>
|
136
|
-
</div>
|
137
|
-
</div>
|
138
118
|
|
139
119
|
|
140
120
|
|
@@ -142,99 +122,6 @@ for this should look something like this:
|
|
142
122
|
|
143
123
|
|
144
124
|
<!-- if method_list -->
|
145
|
-
<div id="methods">
|
146
|
-
<h3 class="section-bar">Public Instance methods</h3>
|
147
|
-
|
148
|
-
<div id="method-M000047" class="method-detail">
|
149
|
-
<a name="M000047"></a>
|
150
|
-
|
151
|
-
<div class="method-heading">
|
152
|
-
<a href="#M000047" class="method-signature">
|
153
|
-
<span class="method-name">get</span><span class="method-args">(key)</span>
|
154
|
-
</a>
|
155
|
-
</div>
|
156
|
-
|
157
|
-
<div class="method-description">
|
158
|
-
<p><a class="source-toggle" href="#"
|
159
|
-
onclick="toggleCode('M000047-source');return false;">[Source]</a></p>
|
160
|
-
<div class="method-source-code" id="M000047-source">
|
161
|
-
<pre>
|
162
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/adapters/file.rb, line 16</span>
|
163
|
-
16: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get</span>(<span class="ruby-identifier">key</span>)
|
164
|
-
17: <span class="ruby-identifier">full_path</span> = <span class="ruby-identifier">full_path_from_dir</span>(<span class="ruby-identifier">get_key_directoy</span>(<span class="ruby-identifier">key</span>, <span class="ruby-keyword kw">false</span>))
|
165
|
-
18: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">full_path</span>)
|
166
|
-
19: <span class="ruby-identifier">so</span> = <span class="ruby-constant">YAML</span><span class="ruby-operator">::</span><span class="ruby-identifier">load</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">full_path</span>).<span class="ruby-identifier">read</span>)
|
167
|
-
20: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">so</span>
|
168
|
-
21: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">so</span>.<span class="ruby-identifier">invalid?</span>
|
169
|
-
22: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">key</span>)
|
170
|
-
23: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
|
171
|
-
24: <span class="ruby-keyword kw">end</span>
|
172
|
-
25: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">so</span>.<span class="ruby-identifier">value</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">YAML</span><span class="ruby-operator">::</span><span class="ruby-constant">Object</span>)
|
173
|
-
26: <span class="ruby-identifier">require</span> <span class="ruby-identifier">so</span>.<span class="ruby-identifier">value</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">underscore</span>
|
174
|
-
27: <span class="ruby-identifier">so</span> = <span class="ruby-constant">YAML</span><span class="ruby-operator">::</span><span class="ruby-identifier">load</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">full_path</span>).<span class="ruby-identifier">read</span>)
|
175
|
-
28: <span class="ruby-keyword kw">end</span>
|
176
|
-
29: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">so</span>.<span class="ruby-identifier">value</span>
|
177
|
-
30: <span class="ruby-keyword kw">end</span>
|
178
|
-
31: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
|
179
|
-
32: <span class="ruby-keyword kw">end</span>
|
180
|
-
</pre>
|
181
|
-
</div>
|
182
|
-
</div>
|
183
|
-
</div>
|
184
|
-
|
185
|
-
<div id="method-M000048" class="method-detail">
|
186
|
-
<a name="M000048"></a>
|
187
|
-
|
188
|
-
<div class="method-heading">
|
189
|
-
<a href="#M000048" class="method-signature">
|
190
|
-
<span class="method-name">set</span><span class="method-args">(key, value, expiry = 0)</span>
|
191
|
-
</a>
|
192
|
-
</div>
|
193
|
-
|
194
|
-
<div class="method-description">
|
195
|
-
<p><a class="source-toggle" href="#"
|
196
|
-
onclick="toggleCode('M000048-source');return false;">[Source]</a></p>
|
197
|
-
<div class="method-source-code" id="M000048-source">
|
198
|
-
<pre>
|
199
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/adapters/file.rb, line 34</span>
|
200
|
-
34: <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-value">0</span>)
|
201
|
-
35: <span class="ruby-identifier">so</span> = <span class="ruby-constant">Cachetastic</span><span class="ruby-operator">::</span><span class="ruby-constant">Adapters</span><span class="ruby-operator">::</span><span class="ruby-constant">StoreObject</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">expiry</span>)
|
202
|
-
36: <span class="ruby-constant">File</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">full_path_from_key</span>(<span class="ruby-identifier">key</span>), <span class="ruby-value str">"w"</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
|
203
|
-
37: <span class="ruby-identifier">f</span>.<span class="ruby-identifier">puts</span> <span class="ruby-constant">YAML</span>.<span class="ruby-identifier">dump</span>(<span class="ruby-identifier">so</span>)
|
204
|
-
38: <span class="ruby-keyword kw">end</span>
|
205
|
-
39: <span class="ruby-keyword kw">end</span>
|
206
|
-
</pre>
|
207
|
-
</div>
|
208
|
-
</div>
|
209
|
-
</div>
|
210
|
-
|
211
|
-
<h3 class="section-bar">Protected Instance methods</h3>
|
212
|
-
|
213
|
-
<div id="method-M000049" class="method-detail">
|
214
|
-
<a name="M000049"></a>
|
215
|
-
|
216
|
-
<div class="method-heading">
|
217
|
-
<a href="#M000049" class="method-signature">
|
218
|
-
<span class="method-name">store_file_name</span><span class="method-args">()</span>
|
219
|
-
</a>
|
220
|
-
</div>
|
221
|
-
|
222
|
-
<div class="method-description">
|
223
|
-
<p><a class="source-toggle" href="#"
|
224
|
-
onclick="toggleCode('M000049-source');return false;">[Source]</a></p>
|
225
|
-
<div class="method-source-code" id="M000049-source">
|
226
|
-
<pre>
|
227
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/adapters/file.rb, line 42</span>
|
228
|
-
42: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">store_file_name</span>
|
229
|
-
43: <span class="ruby-keyword kw">return</span> <span class="ruby-constant">STORE_FILE_NAME</span>
|
230
|
-
44: <span class="ruby-keyword kw">end</span>
|
231
|
-
</pre>
|
232
|
-
</div>
|
233
|
-
</div>
|
234
|
-
</div>
|
235
|
-
|
236
|
-
|
237
|
-
</div>
|
238
125
|
|
239
126
|
|
240
127
|
</div>
|
@@ -82,9 +82,13 @@
|
|
82
82
|
|
83
83
|
<div id="description">
|
84
84
|
<p>
|
85
|
-
An adapter
|
86
|
-
|
87
|
-
|
85
|
+
An adapter to cache objects to memory. It is important to note that this
|
86
|
+
cache is <b>volatile</b>. If the VM it is running in shuts down, everything
|
87
|
+
in the cache gets vaporized.
|
88
|
+
</p>
|
89
|
+
<p>
|
90
|
+
See <tt><a href="Base.html">Cachetastic::Adapters::Base</a></tt> for a list
|
91
|
+
of public API methods.
|
88
92
|
</p>
|
89
93
|
|
90
94
|
</div>
|
@@ -92,19 +96,6 @@ It‘s also a very good example of how to write a adapter.
|
|
92
96
|
|
93
97
|
</div>
|
94
98
|
|
95
|
-
<div id="method-list">
|
96
|
-
<h3 class="section-bar">Methods</h3>
|
97
|
-
|
98
|
-
<div class="name-list">
|
99
|
-
<a href="#M000027">delete</a>
|
100
|
-
<a href="#M000024">expire_all</a>
|
101
|
-
<a href="#M000025">get</a>
|
102
|
-
<a href="#M000026">set</a>
|
103
|
-
<a href="#M000023">setup</a>
|
104
|
-
<a href="#M000028">stats</a>
|
105
|
-
<a href="#M000022">valid?</a>
|
106
|
-
</div>
|
107
|
-
</div>
|
108
99
|
|
109
100
|
</div>
|
110
101
|
|
@@ -117,222 +108,10 @@ It‘s also a very good example of how to write a adapter.
|
|
117
108
|
|
118
109
|
|
119
110
|
|
120
|
-
<div id="attribute-list">
|
121
|
-
<h3 class="section-bar">Attributes</h3>
|
122
|
-
|
123
|
-
<div class="name-list">
|
124
|
-
<table>
|
125
|
-
<tr class="top-aligned-row context-row">
|
126
|
-
<td class="context-item-name">local_store</td>
|
127
|
-
<td class="context-item-value"> [RW] </td>
|
128
|
-
<td class="context-item-desc"></td>
|
129
|
-
</tr>
|
130
|
-
</table>
|
131
|
-
</div>
|
132
|
-
</div>
|
133
111
|
|
134
112
|
|
135
113
|
|
136
114
|
<!-- if method_list -->
|
137
|
-
<div id="methods">
|
138
|
-
<h3 class="section-bar">Public Instance methods</h3>
|
139
|
-
|
140
|
-
<div id="method-M000027" class="method-detail">
|
141
|
-
<a name="M000027"></a>
|
142
|
-
|
143
|
-
<div class="method-heading">
|
144
|
-
<a href="#M000027" class="method-signature">
|
145
|
-
<span class="method-name">delete</span><span class="method-args">(key, delay = 0)</span>
|
146
|
-
</a>
|
147
|
-
</div>
|
148
|
-
|
149
|
-
<div class="method-description">
|
150
|
-
<p><a class="source-toggle" href="#"
|
151
|
-
onclick="toggleCode('M000027-source');return false;">[Source]</a></p>
|
152
|
-
<div class="method-source-code" id="M000027-source">
|
153
|
-
<pre>
|
154
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/adapters/local_memory.rb, line 37</span>
|
155
|
-
37: <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>)
|
156
|
-
38: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">delay</span> <span class="ruby-operator"><=</span> <span class="ruby-value">0</span>
|
157
|
-
39: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">local_store</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>)
|
158
|
-
40: <span class="ruby-keyword kw">else</span>
|
159
|
-
41: <span class="ruby-identifier">so</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">key</span>)
|
160
|
-
42: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">so</span>
|
161
|
-
43: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">set</span>(<span class="ruby-identifier">so</span>.<span class="ruby-identifier">key</span>, <span class="ruby-identifier">so</span>.<span class="ruby-identifier">value</span>, <span class="ruby-identifier">delay</span>)
|
162
|
-
44: <span class="ruby-keyword kw">end</span>
|
163
|
-
45: <span class="ruby-keyword kw">end</span>
|
164
|
-
46: <span class="ruby-keyword kw">end</span>
|
165
|
-
</pre>
|
166
|
-
</div>
|
167
|
-
</div>
|
168
|
-
</div>
|
169
|
-
|
170
|
-
<div id="method-M000024" class="method-detail">
|
171
|
-
<a name="M000024"></a>
|
172
|
-
|
173
|
-
<div class="method-heading">
|
174
|
-
<a href="#M000024" class="method-signature">
|
175
|
-
<span class="method-name">expire_all</span><span class="method-args">()</span>
|
176
|
-
</a>
|
177
|
-
</div>
|
178
|
-
|
179
|
-
<div class="method-description">
|
180
|
-
<p><a class="source-toggle" href="#"
|
181
|
-
onclick="toggleCode('M000024-source');return false;">[Source]</a></p>
|
182
|
-
<div class="method-source-code" id="M000024-source">
|
183
|
-
<pre>
|
184
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/adapters/local_memory.rb, line 16</span>
|
185
|
-
16: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">expire_all</span>
|
186
|
-
17: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">local_store</span> = {}
|
187
|
-
18: <span class="ruby-keyword kw">end</span>
|
188
|
-
</pre>
|
189
|
-
</div>
|
190
|
-
</div>
|
191
|
-
</div>
|
192
|
-
|
193
|
-
<div id="method-M000025" class="method-detail">
|
194
|
-
<a name="M000025"></a>
|
195
|
-
|
196
|
-
<div class="method-heading">
|
197
|
-
<a href="#M000025" class="method-signature">
|
198
|
-
<span class="method-name">get</span><span class="method-args">(key)</span>
|
199
|
-
</a>
|
200
|
-
</div>
|
201
|
-
|
202
|
-
<div class="method-description">
|
203
|
-
<p>
|
204
|
-
See <a href="Base.html">Cachetastic::Adapters::Base</a>
|
205
|
-
</p>
|
206
|
-
<p><a class="source-toggle" href="#"
|
207
|
-
onclick="toggleCode('M000025-source');return false;">[Source]</a></p>
|
208
|
-
<div class="method-source-code" id="M000025-source">
|
209
|
-
<pre>
|
210
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/adapters/local_memory.rb, line 21</span>
|
211
|
-
21: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get</span>(<span class="ruby-identifier">key</span>)
|
212
|
-
22: <span class="ruby-identifier">so</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">local_store</span>[<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>]
|
213
|
-
23: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">so</span>
|
214
|
-
24: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">so</span>.<span class="ruby-identifier">invalid?</span>
|
215
|
-
25: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">key</span>)
|
216
|
-
26: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
|
217
|
-
27: <span class="ruby-keyword kw">end</span>
|
218
|
-
28: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">so</span>.<span class="ruby-identifier">value</span>
|
219
|
-
29: <span class="ruby-keyword kw">end</span>
|
220
|
-
30: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
|
221
|
-
31: <span class="ruby-keyword kw">end</span>
|
222
|
-
</pre>
|
223
|
-
</div>
|
224
|
-
</div>
|
225
|
-
</div>
|
226
|
-
|
227
|
-
<div id="method-M000026" class="method-detail">
|
228
|
-
<a name="M000026"></a>
|
229
|
-
|
230
|
-
<div class="method-heading">
|
231
|
-
<a href="#M000026" class="method-signature">
|
232
|
-
<span class="method-name">set</span><span class="method-args">(key, value, expiry = 0)</span>
|
233
|
-
</a>
|
234
|
-
</div>
|
235
|
-
|
236
|
-
<div class="method-description">
|
237
|
-
<p><a class="source-toggle" href="#"
|
238
|
-
onclick="toggleCode('M000026-source');return false;">[Source]</a></p>
|
239
|
-
<div class="method-source-code" id="M000026-source">
|
240
|
-
<pre>
|
241
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/adapters/local_memory.rb, line 33</span>
|
242
|
-
33: <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-value">0</span>)
|
243
|
-
34: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">local_store</span>[<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>] = <span class="ruby-constant">Cachetastic</span><span class="ruby-operator">::</span><span class="ruby-constant">Adapters</span><span class="ruby-operator">::</span><span class="ruby-constant">StoreObject</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">value</span>, <span class="ruby-identifier">expiry</span>)
|
244
|
-
35: <span class="ruby-keyword kw">end</span>
|
245
|
-
</pre>
|
246
|
-
</div>
|
247
|
-
</div>
|
248
|
-
</div>
|
249
|
-
|
250
|
-
<div id="method-M000023" class="method-detail">
|
251
|
-
<a name="M000023"></a>
|
252
|
-
|
253
|
-
<div class="method-heading">
|
254
|
-
<a href="#M000023" class="method-signature">
|
255
|
-
<span class="method-name">setup</span><span class="method-args">()</span>
|
256
|
-
</a>
|
257
|
-
</div>
|
258
|
-
|
259
|
-
<div class="method-description">
|
260
|
-
<p><a class="source-toggle" href="#"
|
261
|
-
onclick="toggleCode('M000023-source');return false;">[Source]</a></p>
|
262
|
-
<div class="method-source-code" id="M000023-source">
|
263
|
-
<pre>
|
264
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/adapters/local_memory.rb, line 12</span>
|
265
|
-
12: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">setup</span>
|
266
|
-
13: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">local_store</span> = {}
|
267
|
-
14: <span class="ruby-keyword kw">end</span>
|
268
|
-
</pre>
|
269
|
-
</div>
|
270
|
-
</div>
|
271
|
-
</div>
|
272
|
-
|
273
|
-
<div id="method-M000028" class="method-detail">
|
274
|
-
<a name="M000028"></a>
|
275
|
-
|
276
|
-
<div class="method-heading">
|
277
|
-
<a href="#M000028" class="method-signature">
|
278
|
-
<span class="method-name">stats</span><span class="method-args">()</span>
|
279
|
-
</a>
|
280
|
-
</div>
|
281
|
-
|
282
|
-
<div class="method-description">
|
283
|
-
<p><a class="source-toggle" href="#"
|
284
|
-
onclick="toggleCode('M000028-source');return false;">[Source]</a></p>
|
285
|
-
<div class="method-source-code" id="M000028-source">
|
286
|
-
<pre>
|
287
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/adapters/local_memory.rb, line 48</span>
|
288
|
-
48: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stats</span>
|
289
|
-
49: <span class="ruby-keyword kw">super</span>
|
290
|
-
50: <span class="ruby-identifier">num_keys</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">local_store</span>.<span class="ruby-identifier">size</span>
|
291
|
-
51: <span class="ruby-identifier">s</span> = <span class="ruby-node">"Number of Entries: #{num_keys}\n"</span>
|
292
|
-
52: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">num_keys</span> <span class="ruby-operator">></span> <span class="ruby-value">0</span>
|
293
|
-
53: <span class="ruby-identifier">expiries</span> = []
|
294
|
-
54: <span class="ruby-identifier">keys</span> = []
|
295
|
-
55: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">local_store</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>,<span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
|
296
|
-
56: <span class="ruby-identifier">keys</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">key</span>
|
297
|
-
57: <span class="ruby-identifier">expiries</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">expires_at</span>
|
298
|
-
58: <span class="ruby-keyword kw">end</span>
|
299
|
-
59: <span class="ruby-identifier">expiries</span>.<span class="ruby-identifier">sort!</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">x</span>, <span class="ruby-identifier">y</span><span class="ruby-operator">|</span> <span class="ruby-identifier">x</span> <span class="ruby-operator"><=></span> <span class="ruby-identifier">y</span>}
|
300
|
-
60: <span class="ruby-identifier">oldest_expiry</span> = <span class="ruby-identifier">expiries</span>.<span class="ruby-identifier">first</span>
|
301
|
-
61: <span class="ruby-identifier">newest_expiry</span> = <span class="ruby-identifier">expiries</span>.<span class="ruby-identifier">last</span>
|
302
|
-
62: <span class="ruby-identifier">s</span> <span class="ruby-operator">+=</span> <span class="ruby-node">"Oldest Entry: #{oldest_expiry}\nNewest Entry: #{newest_expiry}\nKeys: #{keys.inspect}\n"</span>
|
303
|
-
63: <span class="ruby-keyword kw">end</span>
|
304
|
-
64: <span class="ruby-identifier">puts</span> <span class="ruby-identifier">s</span> <span class="ruby-operator">+</span> <span class="ruby-value str">"\n"</span>
|
305
|
-
65: <span class="ruby-keyword kw">end</span>
|
306
|
-
</pre>
|
307
|
-
</div>
|
308
|
-
</div>
|
309
|
-
</div>
|
310
|
-
|
311
|
-
<div id="method-M000022" class="method-detail">
|
312
|
-
<a name="M000022"></a>
|
313
|
-
|
314
|
-
<div class="method-heading">
|
315
|
-
<a href="#M000022" class="method-signature">
|
316
|
-
<span class="method-name">valid?</span><span class="method-args">()</span>
|
317
|
-
</a>
|
318
|
-
</div>
|
319
|
-
|
320
|
-
<div class="method-description">
|
321
|
-
<p><a class="source-toggle" href="#"
|
322
|
-
onclick="toggleCode('M000022-source');return false;">[Source]</a></p>
|
323
|
-
<div class="method-source-code" id="M000022-source">
|
324
|
-
<pre>
|
325
|
-
<span class="ruby-comment cmt"># File lib/cachetastic/adapters/local_memory.rb, line 8</span>
|
326
|
-
8: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">valid?</span>
|
327
|
-
9: <span class="ruby-keyword kw">true</span>
|
328
|
-
10: <span class="ruby-keyword kw">end</span>
|
329
|
-
</pre>
|
330
|
-
</div>
|
331
|
-
</div>
|
332
|
-
</div>
|
333
|
-
|
334
|
-
|
335
|
-
</div>
|
336
115
|
|
337
116
|
|
338
117
|
</div>
|
@@ -0,0 +1,193 @@
|
|
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::Adapters::Memcached</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::Adapters::Memcached</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../../files/lib/cachetastic/adapters/memcached_rb.html">
|
59
|
+
lib/cachetastic/adapters/memcached.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="Base.html">
|
69
|
+
Cachetastic::Adapters::Base
|
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
|
+
An adapter to cache objects to the file system.
|
86
|
+
</p>
|
87
|
+
<p>
|
88
|
+
This adapter supports the following configuration settings, in addition to
|
89
|
+
the default settings:
|
90
|
+
</p>
|
91
|
+
<pre>
|
92
|
+
configatron.cachetastic.defaults.servers = ['127.0.0.1:11211']
|
93
|
+
configatron.cachetastic.defaults.mc_options = {:c_threshold => 10_000,
|
94
|
+
:compression => true,
|
95
|
+
:debug => false,
|
96
|
+
:readonly => false,
|
97
|
+
:urlencode => false}
|
98
|
+
configatron.cachetastic.delete_delay = 0
|
99
|
+
</pre>
|
100
|
+
<p>
|
101
|
+
The <tt>servers</tt> setting defines an <tt>Array</tt> of Mecached servers,
|
102
|
+
represented as "<host>:<port>".
|
103
|
+
</p>
|
104
|
+
<p>
|
105
|
+
The <tt>mc_options</tt> setting is a <tt>Hash</tt> of settings required by
|
106
|
+
<a href="Memcached.html">Memcached</a>. See the <a
|
107
|
+
href="Memcached.html">Memcached</a> documentation for more information on
|
108
|
+
what the settings mean.
|
109
|
+
</p>
|
110
|
+
<p>
|
111
|
+
The <tt>delete_delay</tt> setting tells <a
|
112
|
+
href="Memcached.html">Memcached</a> how long to wait before it deletes the
|
113
|
+
object. This is not the same as <tt>expiry_time</tt>. It is only used when
|
114
|
+
the <tt>delete</tt> method is called.
|
115
|
+
</p>
|
116
|
+
<p>
|
117
|
+
See <tt><a href="Base.html">Cachetastic::Adapters::Base</a></tt> for a list
|
118
|
+
of public API methods.
|
119
|
+
</p>
|
120
|
+
|
121
|
+
</div>
|
122
|
+
|
123
|
+
|
124
|
+
</div>
|
125
|
+
|
126
|
+
<div id="method-list">
|
127
|
+
<h3 class="section-bar">Methods</h3>
|
128
|
+
|
129
|
+
<div class="name-list">
|
130
|
+
<a href="#M000002">valid?</a>
|
131
|
+
</div>
|
132
|
+
</div>
|
133
|
+
|
134
|
+
</div>
|
135
|
+
|
136
|
+
|
137
|
+
<!-- if includes -->
|
138
|
+
|
139
|
+
<div id="section">
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
<!-- if method_list -->
|
149
|
+
<div id="methods">
|
150
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
151
|
+
|
152
|
+
<div id="method-M000002" class="method-detail">
|
153
|
+
<a name="M000002"></a>
|
154
|
+
|
155
|
+
<div class="method-heading">
|
156
|
+
<a href="#M000002" class="method-signature">
|
157
|
+
<span class="method-name">valid?</span><span class="method-args">()</span>
|
158
|
+
</a>
|
159
|
+
</div>
|
160
|
+
|
161
|
+
<div class="method-description">
|
162
|
+
<p>
|
163
|
+
Return <tt>false</tt> if the connection to <a
|
164
|
+
href="Memcached.html">Memcached</a> is either <tt>nil</tt> or not active.
|
165
|
+
</p>
|
166
|
+
<p><a class="source-toggle" href="#"
|
167
|
+
onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
|
168
|
+
<div class="method-source-code" id="M000002-source">
|
169
|
+
<pre>
|
170
|
+
<span class="ruby-comment cmt"># File lib/cachetastic/adapters/memcached.rb, line 70</span>
|
171
|
+
70: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">valid?</span>
|
172
|
+
71: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@_mc_connection</span>.<span class="ruby-identifier">nil?</span>
|
173
|
+
72: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@_mc_connection</span>.<span class="ruby-identifier">active?</span>
|
174
|
+
73: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
|
175
|
+
74: <span class="ruby-keyword kw">end</span>
|
176
|
+
</pre>
|
177
|
+
</div>
|
178
|
+
</div>
|
179
|
+
</div>
|
180
|
+
|
181
|
+
|
182
|
+
</div>
|
183
|
+
|
184
|
+
|
185
|
+
</div>
|
186
|
+
|
187
|
+
|
188
|
+
<div id="validator-badges">
|
189
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
190
|
+
</div>
|
191
|
+
|
192
|
+
</body>
|
193
|
+
</html>
|