cachetastic-three 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/LICENSE +21 -0
  2. data/README +89 -0
  3. data/doc/classes/Cachetastic/Adapters.html +180 -0
  4. data/doc/classes/Cachetastic/Adapters/Base.html +419 -0
  5. data/doc/classes/Cachetastic/Adapters/File.html +135 -0
  6. data/doc/classes/Cachetastic/Adapters/LocalMemory.html +125 -0
  7. data/doc/classes/Cachetastic/Adapters/Memcached.html +193 -0
  8. data/doc/classes/Cachetastic/Cache.html +425 -0
  9. data/doc/classes/Cachetastic/Cacheable.html +255 -0
  10. data/doc/classes/Cachetastic/Cacheable/ClassAndInstanceMethods.html +290 -0
  11. data/doc/classes/Cachetastic/Cacheable/ClassOnlyMethods.html +197 -0
  12. data/doc/classes/Cachetastic/Logger.html +186 -0
  13. data/doc/created.rid +1 -0
  14. data/doc/files/LICENSE.html +132 -0
  15. data/doc/files/README.html +222 -0
  16. data/doc/files/lib/cachetastic/adapters/base_rb.html +101 -0
  17. data/doc/files/lib/cachetastic/adapters/file_rb.html +101 -0
  18. data/doc/files/lib/cachetastic/adapters/local_memory_rb.html +101 -0
  19. data/doc/files/lib/cachetastic/adapters/memcached_rb.html +101 -0
  20. data/doc/files/lib/cachetastic/cache_rb.html +101 -0
  21. data/doc/files/lib/cachetastic/cacheable_rb.html +101 -0
  22. data/doc/files/lib/cachetastic/extensions/string_rb.html +108 -0
  23. data/doc/files/lib/cachetastic/logger_rb.html +101 -0
  24. data/doc/files/lib/cachetastic/store_object_rb.html +101 -0
  25. data/doc/files/lib/cachetastic_rb.html +112 -0
  26. data/doc/fr_class_index.html +36 -0
  27. data/doc/fr_file_index.html +38 -0
  28. data/doc/fr_method_index.html +52 -0
  29. data/doc/index.html +24 -0
  30. data/doc/rdoc-style.css +208 -0
  31. data/lib/cachetastic.rb +20 -0
  32. data/lib/cachetastic/adapters/base.rb +178 -0
  33. data/lib/cachetastic/adapters/file.rb +66 -0
  34. data/lib/cachetastic/adapters/local_memory.rb +37 -0
  35. data/lib/cachetastic/adapters/memcached.rb +114 -0
  36. data/lib/cachetastic/cache.rb +165 -0
  37. data/lib/cachetastic/cacheable.rb +202 -0
  38. data/lib/cachetastic/extensions/string.rb +8 -0
  39. data/lib/cachetastic/logger.rb +49 -0
  40. data/lib/cachetastic/store_object.rb +22 -0
  41. metadata +122 -0
@@ -0,0 +1,290 @@
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::ClassAndInstanceMethods</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::ClassAndInstanceMethods</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="#M000015">cache_class</a>&nbsp;&nbsp;
84
+ <a href="#M000016">cacher</a>&nbsp;&nbsp;
85
+ <a href="#M000017">expire_all</a>&nbsp;&nbsp;
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-M000015" class="method-detail">
108
+ <a name="M000015"></a>
109
+
110
+ <div class="method-heading">
111
+ <a href="#M000015" class="method-signature">
112
+ <span class="method-name">cache_class</span><span class="method-args">()</span>
113
+ </a>
114
+ </div>
115
+
116
+ <div class="method-description">
117
+ <p>
118
+ Returns the <a href="../Cache.html">Cachetastic::Cache</a> object
119
+ associated with the object. If a cache hasn&#8216;t been defined the one
120
+ will be created on the fly. The cache for the object is expected to be
121
+ defined as: <a
122
+ href="../Cacheable.html">Cachetastic::Cacheable</a>::{CLASS_NAME_HERE}<a
123
+ href="../Cache.html">Cache</a>
124
+ </p>
125
+ <p>
126
+ Examples:
127
+ </p>
128
+ <pre>
129
+ class Person
130
+ include Cachetastic::Cacheable
131
+ end
132
+
133
+ Person.cache_class # =&gt; Cachetastic::Cacheable::PersonCache
134
+
135
+ class Admin::Person
136
+ include Cachetastic::Cacheable
137
+ end
138
+
139
+ Admin::Person.cache_class # =&gt; Cachetastic::Cacheable::Admin_PersonCache
140
+ </pre>
141
+ <p><a class="source-toggle" href="#"
142
+ onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
143
+ <div class="method-source-code" id="M000015-source">
144
+ <pre>
145
+ <span class="ruby-comment cmt"># File lib/cachetastic/cacheable.rb, line 41</span>
146
+ 41: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cache_class</span>
147
+ 42: <span class="ruby-identifier">n</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">name</span>
148
+ 43: <span class="ruby-identifier">n</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">name</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">n</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;Class&quot;</span>
149
+ 44: <span class="ruby-identifier">c_name</span> = <span class="ruby-node">&quot;Cachetastic::Cacheable::#{n.gsub('::', '_')}Cache&quot;</span>
150
+ 45: <span class="ruby-keyword kw">begin</span>
151
+ 46: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">c_name</span>.<span class="ruby-identifier">constantize</span>
152
+ 47: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">NameError</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
153
+ 48: <span class="ruby-identifier">eval</span> <span class="ruby-node">%{
154
+ 49: class #{c_name} &lt; Cachetastic::Cache
155
+ 50:
156
+ 51: def self.cache_klass
157
+ 52: #{n}
158
+ 53: end
159
+ 54:
160
+ 55: end
161
+ 56: }</span>
162
+ 57: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">c_name</span>.<span class="ruby-identifier">constantize</span>
163
+ 58: <span class="ruby-keyword kw">end</span>
164
+ 59:
165
+ 60: <span class="ruby-keyword kw">end</span>
166
+ </pre>
167
+ </div>
168
+ </div>
169
+ </div>
170
+
171
+ <div id="method-M000016" class="method-detail">
172
+ <a name="M000016"></a>
173
+
174
+ <div class="method-heading">
175
+ <a href="#M000016" class="method-signature">
176
+ <span class="method-name">cacher</span><span class="method-args">(key, expiry = nil) {|| ...}</span>
177
+ </a>
178
+ </div>
179
+
180
+ <div class="method-description">
181
+ <p>
182
+ How much did I want to call this method cache?? It originally was that, but
183
+ in Rails 2.0 they decided to use that name, so I had to rename this method.
184
+ This method will attempt to get an object from the cache for a given key.
185
+ If the object is nil and a block is given the block will be run, and the
186
+ results of the block will be automatically cached.
187
+ </p>
188
+ <p>
189
+ Example:
190
+ </p>
191
+ <pre>
192
+ class Person
193
+ include Cachetastic::Cacheable
194
+
195
+ def always_the_same(x,y)
196
+ cacher(&quot;always_the_same&quot;) do
197
+ x + y
198
+ end
199
+ end
200
+ end
201
+
202
+ Person.new.always_the_same(1,2) # =&gt; 3
203
+ Person.new.always_the_same(2,2) # =&gt; 3
204
+ Person.new.always_the_same(3,3) # =&gt; 3
205
+ Person.cacher(&quot;always_the_same&quot;) # =&gt; 3
206
+ Person.get_from_cache(&quot;always_the_same&quot;) # =&gt; 3
207
+ Cachetastic::Cacheable::PersonCache.get(&quot;always_the_same&quot;) # =&gt; 3
208
+
209
+ Person.cacher(&quot;say_hi&quot;) {&quot;Hi There&quot;} # =&gt; &quot;Hi There&quot;
210
+ Person.get_from_cache(&quot;say_hi&quot;) # =&gt; &quot;Hi There&quot;
211
+ Cachetastic::Cacheable::PersonCache.get(&quot;say_hi&quot;) # =&gt; &quot;Hi There&quot;
212
+ </pre>
213
+ <p><a class="source-toggle" href="#"
214
+ onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
215
+ <div class="method-source-code" id="M000016-source">
216
+ <pre>
217
+ <span class="ruby-comment cmt"># File lib/cachetastic/cacheable.rb, line 89</span>
218
+ 89: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">cacher</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">expiry</span> = <span class="ruby-keyword kw">nil</span>)
219
+ 90: <span class="ruby-identifier">cache_class</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">key</span>) <span class="ruby-keyword kw">do</span>
220
+ 91: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
221
+ 92: <span class="ruby-identifier">res</span> = <span class="ruby-keyword kw">yield</span>
222
+ 93: <span class="ruby-identifier">cache_class</span>.<span class="ruby-identifier">set</span>(<span class="ruby-identifier">key</span>, <span class="ruby-identifier">res</span>, <span class="ruby-identifier">expiry</span>)
223
+ 94: <span class="ruby-keyword kw">end</span>
224
+ 95: <span class="ruby-keyword kw">end</span>
225
+ 96: <span class="ruby-keyword kw">end</span>
226
+ </pre>
227
+ </div>
228
+ </div>
229
+ </div>
230
+
231
+ <div id="method-M000017" class="method-detail">
232
+ <a name="M000017"></a>
233
+
234
+ <div class="method-heading">
235
+ <a href="#M000017" class="method-signature">
236
+ <span class="method-name">expire_all</span><span class="method-args">()</span>
237
+ </a>
238
+ </div>
239
+
240
+ <div class="method-description">
241
+ <p>
242
+ Expires the entire cache associated with this objects&#8216;s cache.
243
+ </p>
244
+ <p>
245
+ Example:
246
+ </p>
247
+ <pre>
248
+ class Person
249
+ include Cachetastic::Cacheable
250
+ attr_accessor :name
251
+ def cachetastic_key
252
+ self.name
253
+ end
254
+ end
255
+
256
+ Person.set_into_cache(1, &quot;one&quot;)
257
+ Person.get_from_cache(1) # =&gt; &quot;one&quot;
258
+ Person.expire_all
259
+ Person.get_from_cache(1) # =&gt; nil
260
+ Person.set_into_cache(1, &quot;one&quot;)
261
+ Person.get_from_cache(1) # =&gt; &quot;one&quot;
262
+ Cachetastic::Cacheable::PersonCache.expire_all
263
+ Person.get_from_cache(1) # =&gt; nil
264
+ </pre>
265
+ <p><a class="source-toggle" href="#"
266
+ onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
267
+ <div class="method-source-code" id="M000017-source">
268
+ <pre>
269
+ <span class="ruby-comment cmt"># File lib/cachetastic/cacheable.rb, line 117</span>
270
+ 117: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">expire_all</span>
271
+ 118: <span class="ruby-identifier">cache_class</span>.<span class="ruby-identifier">expire_all</span>
272
+ 119: <span class="ruby-keyword kw">end</span>
273
+ </pre>
274
+ </div>
275
+ </div>
276
+ </div>
277
+
278
+
279
+ </div>
280
+
281
+
282
+ </div>
283
+
284
+
285
+ <div id="validator-badges">
286
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
287
+ </div>
288
+
289
+ </body>
290
+ </html>
@@ -0,0 +1,197 @@
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="#M000013">delete_from_cache</a>&nbsp;&nbsp;
84
+ <a href="#M000012">get_from_cache</a>&nbsp;&nbsp;
85
+ <a href="#M000014">set_into_cache</a>&nbsp;&nbsp;
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-M000013" class="method-detail">
108
+ <a name="M000013"></a>
109
+
110
+ <div class="method-heading">
111
+ <a href="#M000013" 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('M000013-source');return false;">[Source]</a></p>
122
+ <div class="method-source-code" id="M000013-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-M000012" class="method-detail">
134
+ <a name="M000012"></a>
135
+
136
+ <div class="method-heading">
137
+ <a href="#M000012" class="method-signature">
138
+ <span class="method-name">get_from_cache</span><span class="method-args">(key, &amp;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.
145
+ </p>
146
+ <p><a class="source-toggle" href="#"
147
+ onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
148
+ <div class="method-source-code" id="M000012-source">
149
+ <pre>
150
+ <span class="ruby-comment cmt"># File lib/cachetastic/cacheable.rb, line 186</span>
151
+ 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">&amp;</span><span class="ruby-identifier">block</span>)
152
+ 187: <span class="ruby-identifier">cache_class</span>.<span class="ruby-identifier">get</span>(<span class="ruby-identifier">key</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
153
+ 188: <span class="ruby-keyword kw">end</span>
154
+ </pre>
155
+ </div>
156
+ </div>
157
+ </div>
158
+
159
+ <div id="method-M000014" class="method-detail">
160
+ <a name="M000014"></a>
161
+
162
+ <div class="method-heading">
163
+ <a href="#M000014" class="method-signature">
164
+ <span class="method-name">set_into_cache</span><span class="method-args">(key, value, expiry = 0)</span>
165
+ </a>
166
+ </div>
167
+
168
+ <div class="method-description">
169
+ <p>
170
+ Sets an object into the cache for a given key.
171
+ </p>
172
+ <p><a class="source-toggle" href="#"
173
+ onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
174
+ <div class="method-source-code" id="M000014-source">
175
+ <pre>
176
+ <span class="ruby-comment cmt"># File lib/cachetastic/cacheable.rb, line 196</span>
177
+ 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>)
178
+ 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>)
179
+ 198: <span class="ruby-keyword kw">end</span>
180
+ </pre>
181
+ </div>
182
+ </div>
183
+ </div>
184
+
185
+
186
+ </div>
187
+
188
+
189
+ </div>
190
+
191
+
192
+ <div id="validator-badges">
193
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
194
+ </div>
195
+
196
+ </body>
197
+ </html>