frivol 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ begin
11
11
  gem.homepage = "http://github.com/marcheiligers/frivol"
12
12
  gem.authors = ["Marc Heiligers"]
13
13
  gem.add_dependency "json", ">= 1.2.0"
14
- gem.add_dependency "redis", ">= 0.1.2"
14
+ gem.add_dependency "redis", ">= 2.0.10"
15
15
  gem.add_development_dependency "shoulda", ">= 2.11.1"
16
16
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
17
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
@@ -107,6 +107,24 @@ Module <a href="Frivol/Config.html" class="link">Frivol::Config</a><br />
107
107
 
108
108
  </div>
109
109
 
110
+ <div id="constants-list">
111
+ <h3 class="section-bar">Constants</h3>
112
+
113
+ <div class="name-list">
114
+ <table summary="Constants">
115
+ <tr class="top-aligned-row context-row">
116
+ <td class="context-item-name">NEVER_EXPIRE</td>
117
+ <td>=</td>
118
+ <td class="context-item-value">nil</td>
119
+ <td width="3em">&nbsp;</td>
120
+ <td class="context-item-desc">
121
+ Defines a constant to indicate that storage should never expire
122
+
123
+ </td>
124
+ </tr>
125
+ </table>
126
+ </div>
127
+ </div>
110
128
 
111
129
 
112
130
 
@@ -121,7 +139,8 @@ Module <a href="Frivol/Config.html" class="link">Frivol::Config</a><br />
121
139
  <a name="M000005"></a>
122
140
 
123
141
  <div class="method-heading">
124
- <a href="#M000005" class="method-signature">
142
+ <a href="Frivol.src/M000005.html" target="Code" class="method-signature"
143
+ onclick="popupCode('Frivol.src/M000005.html');return false;">
125
144
  <span class="method-name">delete_storage</span><span class="method-args">()</span>
126
145
  </a>
127
146
  </div>
@@ -130,16 +149,6 @@ Module <a href="Frivol/Config.html" class="link">Frivol::Config</a><br />
130
149
  <p>
131
150
  Deletes the stored values.
132
151
  </p>
133
- <p><a class="source-toggle" href="#"
134
- onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
135
- <div class="method-source-code" id="M000005-source">
136
- <pre>
137
- <span class="ruby-comment cmt"># File lib/frivol.rb, line 105</span>
138
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_storage</span>
139
- <span class="ruby-constant">Frivol</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">delete_hash</span> <span class="ruby-keyword kw">self</span>
140
- <span class="ruby-keyword kw">end</span>
141
- </pre>
142
- </div>
143
152
  </div>
144
153
  </div>
145
154
 
@@ -147,8 +156,9 @@ Deletes the stored values.
147
156
  <a name="M000006"></a>
148
157
 
149
158
  <div class="method-heading">
150
- <a href="#M000006" class="method-signature">
151
- <span class="method-name">expire_storage</span><span class="method-args">(time)</span>
159
+ <a href="Frivol.src/M000006.html" target="Code" class="method-signature"
160
+ onclick="popupCode('Frivol.src/M000006.html');return false;">
161
+ <span class="method-name">expire_storage</span><span class="method-args">(time, bucket = nil)</span>
152
162
  </a>
153
163
  </div>
154
164
 
@@ -156,17 +166,6 @@ Deletes the stored values.
156
166
  <p>
157
167
  Expire the stored data in <tt>time</tt> seconds.
158
168
  </p>
159
- <p><a class="source-toggle" href="#"
160
- onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
161
- <div class="method-source-code" id="M000006-source">
162
- <pre>
163
- <span class="ruby-comment cmt"># File lib/frivol.rb, line 110</span>
164
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">expire_storage</span>(<span class="ruby-identifier">time</span>)
165
- <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">time</span>.<span class="ruby-identifier">nil?</span>
166
- <span class="ruby-constant">Frivol</span><span class="ruby-operator">::</span><span class="ruby-constant">Config</span>.<span class="ruby-identifier">redis</span>.<span class="ruby-identifier">expire</span> <span class="ruby-identifier">storage_key</span>, <span class="ruby-identifier">time</span>
167
- <span class="ruby-keyword kw">end</span>
168
- </pre>
169
- </div>
170
169
  </div>
171
170
  </div>
172
171
 
@@ -174,7 +173,8 @@ Expire the stored data in <tt>time</tt> seconds.
174
173
  <a name="M000004"></a>
175
174
 
176
175
  <div class="method-heading">
177
- <a href="#M000004" class="method-signature">
176
+ <a href="Frivol.src/M000004.html" target="Code" class="method-signature"
177
+ onclick="popupCode('Frivol.src/M000004.html');return false;">
178
178
  <span class="method-name">retrieve</span><span class="method-args">(keys_and_defaults)</span>
179
179
  </a>
180
180
  </div>
@@ -198,21 +198,6 @@ to get the default from a method named after that symbol. If the class does
198
198
  not <tt>respond_to?</tt> a method by that name, the symbol will assumed to
199
199
  be the default.
200
200
  </p>
201
- <p><a class="source-toggle" href="#"
202
- onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
203
- <div class="method-source-code" id="M000004-source">
204
- <pre>
205
- <span class="ruby-comment cmt"># File lib/frivol.rb, line 95</span>
206
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">retrieve</span>(<span class="ruby-identifier">keys_and_defaults</span>)
207
- <span class="ruby-constant">Frivol</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">retrieve_hash</span> <span class="ruby-keyword kw">self</span>
208
- <span class="ruby-identifier">result</span> = <span class="ruby-identifier">keys_and_defaults</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">default</span><span class="ruby-operator">|</span>
209
- <span class="ruby-ivar">@frivol_hash</span>[<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>] <span class="ruby-operator">||</span> (<span class="ruby-identifier">default</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Symbol</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">default</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">send</span>(<span class="ruby-identifier">default</span>)) <span class="ruby-operator">||</span> <span class="ruby-identifier">default</span>
210
- <span class="ruby-keyword kw">end</span>
211
- <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">first</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
212
- <span class="ruby-identifier">result</span>
213
- <span class="ruby-keyword kw">end</span>
214
- </pre>
215
- </div>
216
201
  </div>
217
202
  </div>
218
203
 
@@ -220,8 +205,9 @@ be the default.
220
205
  <a name="M000007"></a>
221
206
 
222
207
  <div class="method-heading">
223
- <a href="#M000007" class="method-signature">
224
- <span class="method-name">storage_key</span><span class="method-args">()</span>
208
+ <a href="Frivol.src/M000007.html" target="Code" class="method-signature"
209
+ onclick="popupCode('Frivol.src/M000007.html');return false;">
210
+ <span class="method-name">storage_key</span><span class="method-args">(bucket = nil)</span>
225
211
  </a>
226
212
  </div>
227
213
 
@@ -231,20 +217,15 @@ The base key used for storage in Redis.
231
217
  </p>
232
218
  <p>
233
219
  This method has been implemented for use with ActiveRecord and uses
234
- <tt>&quot;#{self.class.name}-#{id}&quot;</tt> If you are not using
235
- ActiveRecord, or using classes that don&#8216;t respond to id, you should
236
- override this method in your class.
220
+ <tt>&quot;#{self.class.name}-#{id}&quot;</tt> for the default bucket and
221
+ <tt>&quot;#{self.class.name}-#{id}-#{bucket}&quot;</tt> for a named bucket.
222
+ If you are not using ActiveRecord, or using classes that don&#8216;t
223
+ respond to id, you should override this method in your class.
224
+ </p>
225
+ <p>
226
+ NOTE: This method has changed since version 0.1.4, and now has the bucket
227
+ parameter (default: nil)
237
228
  </p>
238
- <p><a class="source-toggle" href="#"
239
- onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
240
- <div class="method-source-code" id="M000007-source">
241
- <pre>
242
- <span class="ruby-comment cmt"># File lib/frivol.rb, line 120</span>
243
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">storage_key</span>
244
- <span class="ruby-ivar">@frivol_key</span> <span class="ruby-operator">||=</span> <span class="ruby-node">&quot;#{self.class.name}-#{id}&quot;</span>
245
- <span class="ruby-keyword kw">end</span>
246
- </pre>
247
- </div>
248
229
  </div>
249
230
  </div>
250
231
 
@@ -252,7 +233,8 @@ override this method in your class.
252
233
  <a name="M000003"></a>
253
234
 
254
235
  <div class="method-heading">
255
- <a href="#M000003" class="method-signature">
236
+ <a href="Frivol.src/M000003.html" target="Code" class="method-signature"
237
+ onclick="popupCode('Frivol.src/M000003.html');return false;">
256
238
  <span class="method-name">store</span><span class="method-args">(keys_and_values)</span>
257
239
  </a>
258
240
  </div>
@@ -271,20 +253,6 @@ call <tt><a href="Frivol.html#M000003">store</a> :value2 =&gt; 2</tt> and
271
253
  retrieves data is intended to be hidden and while it is true that it
272
254
  currently uses a <tt>Hash#to_json</tt> you should not rely on this.
273
255
  </p>
274
- <p><a class="source-toggle" href="#"
275
- onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
276
- <div class="method-source-code" id="M000003-source">
277
- <pre>
278
- <span class="ruby-comment cmt"># File lib/frivol.rb, line 78</span>
279
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">store</span>(<span class="ruby-identifier">keys_and_values</span>)
280
- <span class="ruby-constant">Frivol</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">retrieve_hash</span> <span class="ruby-keyword kw">self</span>
281
- <span class="ruby-identifier">keys_and_values</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>
282
- <span class="ruby-ivar">@frivol_hash</span>[<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>] = <span class="ruby-identifier">value</span>
283
- <span class="ruby-keyword kw">end</span>
284
- <span class="ruby-constant">Frivol</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">store_hash</span> <span class="ruby-keyword kw">self</span>
285
- <span class="ruby-keyword kw">end</span>
286
- </pre>
287
- </div>
288
256
  </div>
289
257
  </div>
290
258
 
@@ -10,13 +10,13 @@
10
10
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/frivol.rb, line 68</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/frivol.rb, line 97</span>
14
14
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">store</span>(<span class="ruby-identifier">keys_and_values</span>)
15
- <span class="ruby-constant">Frivol</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">retrieve_hash</span> <span class="ruby-keyword kw">self</span>
15
+ <span class="ruby-identifier">hash</span> = <span class="ruby-constant">Frivol</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">retrieve_hash</span>(<span class="ruby-keyword kw">self</span>)
16
16
  <span class="ruby-identifier">keys_and_values</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>
17
- <span class="ruby-ivar">@frivol_hash</span>[<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>] = <span class="ruby-identifier">value</span>
17
+ <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>] = <span class="ruby-identifier">value</span>
18
18
  <span class="ruby-keyword kw">end</span>
19
- <span class="ruby-constant">Frivol</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">store_hash</span> <span class="ruby-keyword kw">self</span>
19
+ <span class="ruby-constant">Frivol</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">store_hash</span>(<span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">hash</span>)
20
20
  <span class="ruby-keyword kw">end</span></pre>
21
21
  </body>
22
22
  </html>
@@ -10,11 +10,11 @@
10
10
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/frivol.rb, line 85</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/frivol.rb, line 114</span>
14
14
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">retrieve</span>(<span class="ruby-identifier">keys_and_defaults</span>)
15
- <span class="ruby-constant">Frivol</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">retrieve_hash</span> <span class="ruby-keyword kw">self</span>
15
+ <span class="ruby-identifier">hash</span> = <span class="ruby-constant">Frivol</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">retrieve_hash</span>(<span class="ruby-keyword kw">self</span>)
16
16
  <span class="ruby-identifier">result</span> = <span class="ruby-identifier">keys_and_defaults</span>.<span class="ruby-identifier">map</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">default</span><span class="ruby-operator">|</span>
17
- <span class="ruby-ivar">@frivol_hash</span>[<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>] <span class="ruby-operator">||</span> (<span class="ruby-identifier">default</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Symbol</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">default</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">send</span>(<span class="ruby-identifier">default</span>)) <span class="ruby-operator">||</span> <span class="ruby-identifier">default</span>
17
+ <span class="ruby-identifier">hash</span>[<span class="ruby-identifier">key</span>.<span class="ruby-identifier">to_s</span>] <span class="ruby-operator">||</span> (<span class="ruby-identifier">default</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Symbol</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">default</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">send</span>(<span class="ruby-identifier">default</span>)) <span class="ruby-operator">||</span> <span class="ruby-identifier">default</span>
18
18
  <span class="ruby-keyword kw">end</span>
19
19
  <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">first</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">result</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
20
20
  <span class="ruby-identifier">result</span>
@@ -5,15 +5,14 @@
5
5
 
6
6
  <html>
7
7
  <head>
8
- <title>expire_storage (Frivol)</title>
8
+ <title>delete_storage (Frivol)</title>
9
9
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
10
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/frivol.rb, line 95</span>
14
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">expire_storage</span>(<span class="ruby-identifier">time</span>)
15
- <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">time</span>.<span class="ruby-identifier">nil?</span>
16
- <span class="ruby-constant">Frivol</span><span class="ruby-operator">::</span><span class="ruby-constant">Config</span>.<span class="ruby-identifier">redis</span>.<span class="ruby-identifier">expire</span> <span class="ruby-identifier">storage_key</span>, <span class="ruby-identifier">time</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/frivol.rb, line 124</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete_storage</span>
15
+ <span class="ruby-constant">Frivol</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">delete_hash</span> <span class="ruby-keyword kw">self</span>
17
16
  <span class="ruby-keyword kw">end</span></pre>
18
17
  </body>
19
18
  </html>
@@ -5,14 +5,15 @@
5
5
 
6
6
  <html>
7
7
  <head>
8
- <title>storage_key (Frivol)</title>
8
+ <title>expire_storage (Frivol)</title>
9
9
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
10
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/frivol.rb, line 105</span>
14
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">storage_key</span>
15
- <span class="ruby-ivar">@frivol_key</span> <span class="ruby-operator">||=</span> <span class="ruby-node">&quot;#{self.class.name}-#{id}&quot;</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/frivol.rb, line 129</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">expire_storage</span>(<span class="ruby-identifier">time</span>, <span class="ruby-identifier">bucket</span> = <span class="ruby-keyword kw">nil</span>)
15
+ <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">time</span>.<span class="ruby-identifier">nil?</span>
16
+ <span class="ruby-constant">Frivol</span><span class="ruby-operator">::</span><span class="ruby-constant">Config</span>.<span class="ruby-identifier">redis</span>.<span class="ruby-identifier">expire</span> <span class="ruby-identifier">storage_key</span>(<span class="ruby-identifier">bucket</span>), <span class="ruby-identifier">time</span>
16
17
  <span class="ruby-keyword kw">end</span></pre>
17
18
  </body>
18
19
  </html>
@@ -0,0 +1,19 @@
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>
7
+ <head>
8
+ <title>storage_key (Frivol)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/frivol.rb, line 142</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">storage_key</span>(<span class="ruby-identifier">bucket</span> = <span class="ruby-keyword kw">nil</span>)
15
+ <span class="ruby-ivar">@frivol_key</span> <span class="ruby-operator">||=</span> <span class="ruby-node">&quot;#{self.class.name}-#{id}&quot;</span>
16
+ <span class="ruby-identifier">bucket</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-value">? </span><span class="ruby-ivar">@frivol_key</span> <span class="ruby-operator">:</span> <span class="ruby-node">&quot;#{@frivol_key}-#{bucket}&quot;</span>
17
+ <span class="ruby-keyword kw">end</span></pre>
18
+ </body>
19
+ </html>
@@ -88,6 +88,7 @@ href="../Frivol.html">Frivol</a> is included in the class.
88
88
  <h3 class="section-bar">Methods</h3>
89
89
 
90
90
  <div class="name-list">
91
+ <a href="#M000010">storage_bucket</a>&nbsp;&nbsp;
91
92
  <a href="#M000008">storage_expires_in</a>&nbsp;&nbsp;
92
93
  <a href="#M000009">storage_expiry</a>&nbsp;&nbsp;
93
94
  </div>
@@ -111,29 +112,72 @@ href="../Frivol.html">Frivol</a> is included in the class.
111
112
  <div id="methods">
112
113
  <h3 class="section-bar">Public Instance methods</h3>
113
114
 
115
+ <div id="method-M000010" class="method-detail">
116
+ <a name="M000010"></a>
117
+
118
+ <div class="method-heading">
119
+ <a href="ClassMethods.src/M000010.html" target="Code" class="method-signature"
120
+ onclick="popupCode('ClassMethods.src/M000010.html');return false;">
121
+ <span class="method-name">storage_bucket</span><span class="method-args">(bucket, options = {})</span>
122
+ </a>
123
+ </div>
124
+
125
+ <div class="method-description">
126
+ <p>
127
+ Create a storage bucket. <a href="../Frivol.html">Frivol</a> creates
128
+ store_#{bucket} and retrieve_#{bucket} methods automatically. These methods
129
+ work exactly like the default store and retrieve methods except that the
130
+ bucket is stored in it&#8216;s own key in Redis and can have it&#8216;s own
131
+ expiry time.
132
+ </p>
133
+ <p>
134
+ Counters are special in that they do not store a hash but only a single
135
+ integer value and also that the data in a counter is not cached for the
136
+ lifespan of the object, but rather each call hits Redis. This is intended
137
+ to make counters thread safe (for example you may have multiple workers
138
+ working on a job and they can each increment a progress counter which would
139
+ not work with the default retrieve/store method that normal buckets use).
140
+ For this to actually be thread safe you need to pass the thread safe option
141
+ to the config when you make the connection.
142
+ </p>
143
+ <p>
144
+ In the case of a counter, the methods work slightly differently:
145
+ </p>
146
+ <ul>
147
+ <li>store_#{bucket} only takes an integer value to store (no key)
148
+
149
+ </li>
150
+ <li>retrieve_#{bucket} only takes an integer default, and returns only the
151
+ integer value
152
+
153
+ </li>
154
+ <li>there is an added increment_#{bucket} method which increments the counter
155
+ by 1
156
+
157
+ </li>
158
+ </ul>
159
+ <p>
160
+ Options are :expires_in which sets the expiry time for a bucket, and
161
+ :counter to create a special counter storage bucket.
162
+ </p>
163
+ </div>
164
+ </div>
165
+
114
166
  <div id="method-M000008" class="method-detail">
115
167
  <a name="M000008"></a>
116
168
 
117
169
  <div class="method-heading">
118
- <a href="#M000008" class="method-signature">
119
- <span class="method-name">storage_expires_in</span><span class="method-args">(time)</span>
170
+ <a href="ClassMethods.src/M000008.html" target="Code" class="method-signature"
171
+ onclick="popupCode('ClassMethods.src/M000008.html');return false;">
172
+ <span class="method-name">storage_expires_in</span><span class="method-args">(time, bucket = nil)</span>
120
173
  </a>
121
174
  </div>
122
175
 
123
176
  <div class="method-description">
124
177
  <p>
125
- Set the storage expiry time in seconds.
178
+ Set the storage expiry time in seconds for the default bucket or the bucket
179
+ passed.
126
180
  </p>
127
- <p><a class="source-toggle" href="#"
128
- onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
129
- <div class="method-source-code" id="M000008-source">
130
- <pre>
131
- <span class="ruby-comment cmt"># File lib/frivol.rb, line 190</span>
132
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">storage_expires_in</span>(<span class="ruby-identifier">time</span>)
133
- <span class="ruby-ivar">@frivol_storage_expiry</span> = <span class="ruby-identifier">time</span>
134
- <span class="ruby-keyword kw">end</span>
135
- </pre>
136
- </div>
137
181
  </div>
138
182
  </div>
139
183
 
@@ -141,25 +185,17 @@ Set the storage expiry time in seconds.
141
185
  <a name="M000009"></a>
142
186
 
143
187
  <div class="method-heading">
144
- <a href="#M000009" class="method-signature">
145
- <span class="method-name">storage_expiry</span><span class="method-args">()</span>
188
+ <a href="ClassMethods.src/M000009.html" target="Code" class="method-signature"
189
+ onclick="popupCode('ClassMethods.src/M000009.html');return false;">
190
+ <span class="method-name">storage_expiry</span><span class="method-args">(bucket = nil)</span>
146
191
  </a>
147
192
  </div>
148
193
 
149
194
  <div class="method-description">
150
195
  <p>
151
- Get the storage expiry time in seconds.
196
+ Get the storage expiry time in seconds for the default bucket or the bucket
197
+ passed.
152
198
  </p>
153
- <p><a class="source-toggle" href="#"
154
- onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
155
- <div class="method-source-code" id="M000009-source">
156
- <pre>
157
- <span class="ruby-comment cmt"># File lib/frivol.rb, line 195</span>
158
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">storage_expiry</span>
159
- <span class="ruby-ivar">@frivol_storage_expiry</span>
160
- <span class="ruby-keyword kw">end</span>
161
- </pre>
162
- </div>
163
199
  </div>
164
200
  </div>
165
201
 
@@ -5,14 +5,15 @@
5
5
 
6
6
  <html>
7
7
  <head>
8
- <title>storage_expiry (Frivol::ClassMethods)</title>
8
+ <title>storage_expires_in (Frivol::ClassMethods)</title>
9
9
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
10
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
11
  </head>
12
12
  <body class="standalone-code">
13
- <pre><span class="ruby-comment cmt"># File lib/frivol.rb, line 174</span>
14
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">storage_expiry</span>
15
- <span class="ruby-ivar">@frivol_storage_expiry</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/frivol.rb, line 246</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">storage_expires_in</span>(<span class="ruby-identifier">time</span>, <span class="ruby-identifier">bucket</span> = <span class="ruby-keyword kw">nil</span>)
15
+ <span class="ruby-ivar">@frivol_storage_expiry</span> <span class="ruby-operator">||=</span> {}
16
+ <span class="ruby-ivar">@frivol_storage_expiry</span>[<span class="ruby-identifier">bucket</span>.<span class="ruby-identifier">to_s</span>] = <span class="ruby-identifier">time</span>
16
17
  <span class="ruby-keyword kw">end</span></pre>
17
18
  </body>
18
19
  </html>
@@ -0,0 +1,19 @@
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>
7
+ <head>
8
+ <title>storage_expiry (Frivol::ClassMethods)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/frivol.rb, line 252</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">storage_expiry</span>(<span class="ruby-identifier">bucket</span> = <span class="ruby-keyword kw">nil</span>)
15
+ <span class="ruby-ivar">@frivol_storage_expiry</span> <span class="ruby-operator">||=</span> {}
16
+ <span class="ruby-ivar">@frivol_storage_expiry</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">bucket</span>.<span class="ruby-identifier">to_s</span>) <span class="ruby-operator">?</span> <span class="ruby-ivar">@frivol_storage_expiry</span>[<span class="ruby-identifier">bucket</span>.<span class="ruby-identifier">to_s</span>] <span class="ruby-operator">:</span> <span class="ruby-constant">NEVER_EXPIRE</span>
17
+ <span class="ruby-keyword kw">end</span></pre>
18
+ </body>
19
+ </html>