frivol 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,53 @@
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_bucket (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 276</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">storage_bucket</span>(<span class="ruby-identifier">bucket</span>, <span class="ruby-identifier">options</span> = {})
15
+ <span class="ruby-identifier">time</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:expires_in</span>]
16
+ <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">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">time</span>.<span class="ruby-identifier">nil?</span>
17
+ <span class="ruby-identifier">is_counter</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:counter</span>]
18
+
19
+ <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class_eval</span> <span class="ruby-keyword kw">do</span>
20
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">is_counter</span>
21
+ <span class="ruby-identifier">define_method</span> <span class="ruby-node">&quot;store_#{bucket}&quot;</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
22
+ <span class="ruby-constant">Frivol</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">store_counter</span>(<span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">bucket</span>, <span class="ruby-identifier">value</span>)
23
+ <span class="ruby-keyword kw">end</span>
24
+
25
+ <span class="ruby-identifier">define_method</span> <span class="ruby-node">&quot;retrieve_#{bucket}&quot;</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">default</span><span class="ruby-operator">|</span>
26
+ <span class="ruby-constant">Frivol</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">retrieve_counter</span>(<span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">bucket</span>, <span class="ruby-identifier">default</span>)
27
+ <span class="ruby-keyword kw">end</span>
28
+
29
+ <span class="ruby-identifier">define_method</span> <span class="ruby-node">&quot;increment_#{bucket}&quot;</span> <span class="ruby-keyword kw">do</span>
30
+ <span class="ruby-constant">Frivol</span><span class="ruby-operator">::</span><span class="ruby-constant">Helpers</span>.<span class="ruby-identifier">increment_counter</span>(<span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">bucket</span>)
31
+ <span class="ruby-keyword kw">end</span>
32
+ <span class="ruby-keyword kw">else</span>
33
+ <span class="ruby-identifier">define_method</span> <span class="ruby-node">&quot;store_#{bucket}&quot;</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">keys_and_values</span><span class="ruby-operator">|</span>
34
+ <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>, <span class="ruby-identifier">bucket</span>)
35
+ <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>
36
+ <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>
37
+ <span class="ruby-keyword kw">end</span>
38
+ <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>, <span class="ruby-identifier">bucket</span>)
39
+ <span class="ruby-keyword kw">end</span>
40
+
41
+ <span class="ruby-identifier">define_method</span> <span class="ruby-node">&quot;retrieve_#{bucket}&quot;</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">keys_and_defaults</span><span class="ruby-operator">|</span>
42
+ <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>, <span class="ruby-identifier">bucket</span>)
43
+ <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>
44
+ <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>
45
+ <span class="ruby-keyword kw">end</span>
46
+ <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>
47
+ <span class="ruby-identifier">result</span>
48
+ <span class="ruby-keyword kw">end</span>
49
+ <span class="ruby-keyword kw">end</span>
50
+ <span class="ruby-keyword kw">end</span>
51
+ <span class="ruby-keyword kw">end</span></pre>
52
+ </body>
53
+ </html>
@@ -90,9 +90,9 @@ with an optional storage expiry parameter
90
90
  <h3 class="section-bar">Methods</h3>
91
91
 
92
92
  <div class="name-list">
93
- <a href="#M000012">include_in</a>&nbsp;&nbsp;
94
- <a href="#M000011">redis</a>&nbsp;&nbsp;
95
- <a href="#M000010">redis_config=</a>&nbsp;&nbsp;
93
+ <a href="#M000013">include_in</a>&nbsp;&nbsp;
94
+ <a href="#M000012">redis</a>&nbsp;&nbsp;
95
+ <a href="#M000011">redis_config=</a>&nbsp;&nbsp;
96
96
  </div>
97
97
  </div>
98
98
 
@@ -114,11 +114,12 @@ with an optional storage expiry parameter
114
114
  <div id="methods">
115
115
  <h3 class="section-bar">Public Class methods</h3>
116
116
 
117
- <div id="method-M000012" class="method-detail">
118
- <a name="M000012"></a>
117
+ <div id="method-M000013" class="method-detail">
118
+ <a name="M000013"></a>
119
119
 
120
120
  <div class="method-heading">
121
- <a href="#M000012" class="method-signature">
121
+ <a href="Config.src/M000013.html" target="Code" class="method-signature"
122
+ onclick="popupCode('Config.src/M000013.html');return false;">
122
123
  <span class="method-name">include_in</span><span class="method-args">(host_class, storage_expires_in = nil)</span>
123
124
  </a>
124
125
  </div>
@@ -139,25 +140,15 @@ For example, you might have the following in environment.rb:
139
140
  Which would include <a href="../Frivol.html">Frivol</a> in
140
141
  ActiveRecord::Base and set the default storage expiry to 10 minutes
141
142
  </p>
142
- <p><a class="source-toggle" href="#"
143
- onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
144
- <div class="method-source-code" id="M000012-source">
145
- <pre>
146
- <span class="ruby-comment cmt"># File lib/frivol.rb, line 151</span>
147
- <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">include_in</span>(<span class="ruby-identifier">host_class</span>, <span class="ruby-identifier">storage_expires_in</span> = <span class="ruby-keyword kw">nil</span>)
148
- <span class="ruby-identifier">host_class</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">:include</span>, <span class="ruby-constant">Frivol</span>)
149
- <span class="ruby-identifier">host_class</span>.<span class="ruby-identifier">storage_expires_in</span> <span class="ruby-identifier">storage_expires_in</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">storage_expires_in</span>
150
- <span class="ruby-keyword kw">end</span>
151
- </pre>
152
- </div>
153
143
  </div>
154
144
  </div>
155
145
 
156
- <div id="method-M000011" class="method-detail">
157
- <a name="M000011"></a>
146
+ <div id="method-M000012" class="method-detail">
147
+ <a name="M000012"></a>
158
148
 
159
149
  <div class="method-heading">
160
- <a href="#M000011" class="method-signature">
150
+ <a href="Config.src/M000012.html" target="Code" class="method-signature"
151
+ onclick="popupCode('Config.src/M000012.html');return false;">
161
152
  <span class="method-name">redis</span><span class="method-args">()</span>
162
153
  </a>
163
154
  </div>
@@ -166,24 +157,15 @@ ActiveRecord::Base and set the default storage expiry to 10 minutes
166
157
  <p>
167
158
  Returns the configured Redis instance
168
159
  </p>
169
- <p><a class="source-toggle" href="#"
170
- onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
171
- <div class="method-source-code" id="M000011-source">
172
- <pre>
173
- <span class="ruby-comment cmt"># File lib/frivol.rb, line 141</span>
174
- <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">redis</span>
175
- <span class="ruby-ivar">@@redis</span>
176
- <span class="ruby-keyword kw">end</span>
177
- </pre>
178
- </div>
179
160
  </div>
180
161
  </div>
181
162
 
182
- <div id="method-M000010" class="method-detail">
183
- <a name="M000010"></a>
163
+ <div id="method-M000011" class="method-detail">
164
+ <a name="M000011"></a>
184
165
 
185
166
  <div class="method-heading">
186
- <a href="#M000010" class="method-signature">
167
+ <a href="Config.src/M000011.html" target="Code" class="method-signature"
168
+ onclick="popupCode('Config.src/M000011.html');return false;">
187
169
  <span class="method-name">redis_config=</span><span class="method-args">(config)</span>
188
170
  </a>
189
171
  </div>
@@ -202,16 +184,6 @@ Expects a hash such as
202
184
  }
203
185
  Frivol::Config.redis_config = REDIS_CONFIG
204
186
  </pre>
205
- <p><a class="source-toggle" href="#"
206
- onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
207
- <div class="method-source-code" id="M000010-source">
208
- <pre>
209
- <span class="ruby-comment cmt"># File lib/frivol.rb, line 136</span>
210
- <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">redis_config=</span>(<span class="ruby-identifier">config</span>)
211
- <span class="ruby-ivar">@@redis</span> = <span class="ruby-constant">Redis</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">config</span>)
212
- <span class="ruby-keyword kw">end</span>
213
- </pre>
214
- </div>
215
187
  </div>
216
188
  </div>
217
189
 
@@ -5,15 +5,14 @@
5
5
 
6
6
  <html>
7
7
  <head>
8
- <title>include_in (Frivol::Config)</title>
8
+ <title>redis_config= (Frivol::Config)</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 136</span>
14
- <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">include_in</span>(<span class="ruby-identifier">host_class</span>, <span class="ruby-identifier">storage_expires_in</span> = <span class="ruby-keyword kw">nil</span>)
15
- <span class="ruby-identifier">host_class</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">:include</span>, <span class="ruby-constant">Frivol</span>)
16
- <span class="ruby-identifier">host_class</span>.<span class="ruby-identifier">storage_expires_in</span> <span class="ruby-identifier">storage_expires_in</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">storage_expires_in</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/frivol.rb, line 159</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">redis_config=</span>(<span class="ruby-identifier">config</span>)
15
+ <span class="ruby-ivar">@@redis</span> = <span class="ruby-constant">Redis</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">config</span>)
17
16
  <span class="ruby-keyword kw">end</span></pre>
18
17
  </body>
19
18
  </html>
@@ -0,0 +1,18 @@
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>redis (Frivol::Config)</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 164</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">redis</span>
15
+ <span class="ruby-ivar">@@redis</span>
16
+ <span class="ruby-keyword kw">end</span></pre>
17
+ </body>
18
+ </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>include_in (Frivol::Config)</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 174</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">include_in</span>(<span class="ruby-identifier">host_class</span>, <span class="ruby-identifier">storage_expires_in</span> = <span class="ruby-keyword kw">nil</span>)
15
+ <span class="ruby-identifier">host_class</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">:include</span>, <span class="ruby-constant">Frivol</span>)
16
+ <span class="ruby-identifier">host_class</span>.<span class="ruby-identifier">storage_expires_in</span> <span class="ruby-identifier">storage_expires_in</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">storage_expires_in</span>
17
+ <span class="ruby-keyword kw">end</span></pre>
18
+ </body>
19
+ </html>
@@ -123,7 +123,8 @@ href="Time.html#M000001">to_json</a></tt> and deserialized by
123
123
  <a name="M000002"></a>
124
124
 
125
125
  <div class="method-heading">
126
- <a href="#M000002" class="method-signature">
126
+ <a href="Time.src/M000002.html" target="Code" class="method-signature"
127
+ onclick="popupCode('Time.src/M000002.html');return false;">
127
128
  <span class="method-name">json_create</span><span class="method-args">(o)</span>
128
129
  </a>
129
130
  </div>
@@ -132,16 +133,6 @@ href="Time.html#M000001">to_json</a></tt> and deserialized by
132
133
  <p>
133
134
  Deserialize from JSON
134
135
  </p>
135
- <p><a class="source-toggle" href="#"
136
- onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
137
- <div class="method-source-code" id="M000002-source">
138
- <pre>
139
- <span class="ruby-comment cmt"># File lib/frivol.rb, line 217</span>
140
- <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">json_create</span>(<span class="ruby-identifier">o</span>)
141
- <span class="ruby-constant">Time</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">o</span>[<span class="ruby-value str">'data'</span>])
142
- <span class="ruby-keyword kw">end</span>
143
- </pre>
144
- </div>
145
136
  </div>
146
137
  </div>
147
138
 
@@ -151,7 +142,8 @@ Deserialize from JSON
151
142
  <a name="M000001"></a>
152
143
 
153
144
  <div class="method-heading">
154
- <a href="#M000001" class="method-signature">
145
+ <a href="Time.src/M000001.html" target="Code" class="method-signature"
146
+ onclick="popupCode('Time.src/M000001.html');return false;">
155
147
  <span class="method-name">to_json</span><span class="method-args">(*a)</span>
156
148
  </a>
157
149
  </div>
@@ -160,19 +152,6 @@ Deserialize from JSON
160
152
  <p>
161
153
  Serialize to JSON
162
154
  </p>
163
- <p><a class="source-toggle" href="#"
164
- onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
165
- <div class="method-source-code" id="M000001-source">
166
- <pre>
167
- <span class="ruby-comment cmt"># File lib/frivol.rb, line 209</span>
168
- <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_json</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">a</span>)
169
- {
170
- <span class="ruby-value str">'json_class'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">name</span>,
171
- <span class="ruby-value str">'data'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">to_s</span>
172
- }.<span class="ruby-identifier">to_json</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">a</span>)
173
- <span class="ruby-keyword kw">end</span>
174
- </pre>
175
- </div>
176
155
  </div>
177
156
  </div>
178
157
 
@@ -10,7 +10,7 @@
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 188</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/frivol.rb, line 330</span>
14
14
  <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_json</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">a</span>)
15
15
  {
16
16
  <span class="ruby-value str">'json_class'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">name</span>,
@@ -10,7 +10,7 @@
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 196</span>
13
+ <pre><span class="ruby-comment cmt"># File lib/frivol.rb, line 338</span>
14
14
  <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">json_create</span>(<span class="ruby-identifier">o</span>)
15
15
  <span class="ruby-constant">Time</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">o</span>[<span class="ruby-value str">'data'</span>])
16
16
  <span class="ruby-keyword kw">end</span></pre>
@@ -1 +1 @@
1
- Sun, 22 Aug 2010 15:20:50 +0200
1
+ Fri, 15 Oct 2010 11:43:06 +0200
@@ -56,7 +56,7 @@
56
56
  </tr>
57
57
  <tr class="top-aligned-row">
58
58
  <td><strong>Last Update:</strong></td>
59
- <td>Sun Aug 22 15:18:58 +0200 2010</td>
59
+ <td>Fri Oct 15 11:30:46 +0200 2010</td>
60
60
  </tr>
61
61
  </table>
62
62
  </div>
@@ -79,9 +79,9 @@ really.
79
79
  I developed <a href="../../classes/Frivol.html">Frivol</a> secifically for
80
80
  use in Mad Mimi (<a href="http://madmimi.com">madmimi.com</a>) to help with
81
81
  caching of data which requires fairly long running (multi-second) database
82
- queries, and also to aid with communication of status from background tasks
83
- running in Resque on workers to the front end web servers. Redis was chosen
84
- because we already had Resque, which is Redis-backed. Also, unlike
82
+ queries, and also to aid with communication of status from background
83
+ Resque jobs running on the workers to the front end web servers. Redis was
84
+ chosen because we already had Resque, which is Redis-backed. Also, unlike
85
85
  memcached, Redis persists it&#8216;s data to disk, meaning there is far
86
86
  less warmup required when a hot system is restarted. <a
87
87
  href="../../classes/Frivol.html">Frivol</a>&#8216;s design is such that it
@@ -117,6 +117,35 @@ href="../../classes/Frivol.html">Frivol</a> will check if the class
117
117
  The <tt>expire_storage(time)</tt> method can be used to set the expiry time
118
118
  in seconds of the temporary storage. The default is not to expire the
119
119
  storage, in which case it will live for as long as Redis keeps it.
120
+ <tt>delete_storage</tt>, as the name suggests will immediately delete the
121
+ storage.
122
+ </p>
123
+ <p>
124
+ Since version 0.1.5 <a href="../../classes/Frivol.html">Frivol</a> can
125
+ create different storage buckets. Note that this introduces a breaking
126
+ change to the <tt>storage_key</tt> method if you have overriden it. It now
127
+ takes a <tt>bucket</tt> parameter.
128
+ </p>
129
+ <p>
130
+ Buckets can have their own expiry time and there are special counter
131
+ buckets which simply keep an integer count.
132
+ </p>
133
+ <pre>
134
+ storage_bucket :my_bucket, :expires_in =&gt; 5.minutes
135
+ storage_bucket :my_counter, :counter =&gt; true
136
+ </pre>
137
+ <p>
138
+ Given the above, <a href="../../classes/Frivol.html">Frivol</a> will create
139
+ <tt>store_my_bucket</tt> and <tt>retrieve_my_bucket</tt> methods which work
140
+ exactly like the standard <tt>store</tt> and <tt>retrieve</tt> methods.
141
+ There will also be <tt>store_my_counter</tt>, <tt>retrieve_my_counter</tt>
142
+ and <tt>increment_my_counter</tt> methods. The counter store and retrieve
143
+ only take a integer (value and default, respectively) and the increment
144
+ does not take a parameter.
145
+ </p>
146
+ <p>
147
+ These methods are thread safe if you pass <tt>:thread_safe =&gt; true</tt>
148
+ to the Redis configuration.
120
149
  </p>
121
150
  <p>
122
151
  <a href="../../classes/Frivol.html">Frivol</a> uses the
@@ -140,8 +169,8 @@ JSON, which currently used to store data in Redis.
140
169
  @key = key
141
170
  end
142
171
 
143
- def storage_key
144
- &quot;frivol-test-#{key}&quot; # override the storage key because we don't respond_to? id
172
+ def storage_key(bucket = nil)
173
+ &quot;frivol-test-#{key}&quot; # override the storage key because we don't respond_to? :id, and don't care about buckets
145
174
  end
146
175
 
147
176
  def big_complex_calc
@@ -22,11 +22,12 @@
22
22
  <div id="index-entries">
23
23
  <a href="classes/Frivol.html#M000005">delete_storage (Frivol)</a><br />
24
24
  <a href="classes/Frivol.html#M000006">expire_storage (Frivol)</a><br />
25
- <a href="classes/Frivol/Config.html#M000012">include_in (Frivol::Config)</a><br />
25
+ <a href="classes/Frivol/Config.html#M000013">include_in (Frivol::Config)</a><br />
26
26
  <a href="classes/Time.html#M000002">json_create (Time)</a><br />
27
- <a href="classes/Frivol/Config.html#M000011">redis (Frivol::Config)</a><br />
28
- <a href="classes/Frivol/Config.html#M000010">redis_config= (Frivol::Config)</a><br />
27
+ <a href="classes/Frivol/Config.html#M000012">redis (Frivol::Config)</a><br />
28
+ <a href="classes/Frivol/Config.html#M000011">redis_config= (Frivol::Config)</a><br />
29
29
  <a href="classes/Frivol.html#M000004">retrieve (Frivol)</a><br />
30
+ <a href="classes/Frivol/ClassMethods.html#M000010">storage_bucket (Frivol::ClassMethods)</a><br />
30
31
  <a href="classes/Frivol/ClassMethods.html#M000008">storage_expires_in (Frivol::ClassMethods)</a><br />
31
32
  <a href="classes/Frivol/ClassMethods.html#M000009">storage_expiry (Frivol::ClassMethods)</a><br />
32
33
  <a href="classes/Frivol.html#M000007">storage_key (Frivol)</a><br />
@@ -5,12 +5,12 @@
5
5
 
6
6
  <!--
7
7
 
8
- Frivol - Frivolously simple temporary storage backed by Redis
8
+ RDoc Documentation
9
9
 
10
10
  -->
11
11
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
12
12
  <head>
13
- <title>Frivol - Frivolously simple temporary storage backed by Redis</title>
13
+ <title>RDoc Documentation</title>
14
14
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
15
15
  </head>
16
16
  <frameset rows="20%, 80%">
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{frivol}
8
- s.version = "0.1.4"
8
+ s.version = "0.1.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Marc Heiligers"]
12
- s.date = %q{2010-08-22}
12
+ s.date = %q{2010-10-15}
13
13
  s.description = %q{Simple Redis backed temporary storage intended primarily for use with ActiveRecord models to provide caching}
14
14
  s.email = %q{marc@eternal.co.za}
15
15
  s.extra_rdoc_files = [
@@ -28,13 +28,18 @@ Gem::Specification.new do |s|
28
28
  "doc/classes/Frivol.src/M000004.html",
29
29
  "doc/classes/Frivol.src/M000005.html",
30
30
  "doc/classes/Frivol.src/M000006.html",
31
+ "doc/classes/Frivol.src/M000007.html",
31
32
  "doc/classes/Frivol/ClassMethods.html",
32
33
  "doc/classes/Frivol/ClassMethods.src/M000007.html",
33
34
  "doc/classes/Frivol/ClassMethods.src/M000008.html",
35
+ "doc/classes/Frivol/ClassMethods.src/M000009.html",
36
+ "doc/classes/Frivol/ClassMethods.src/M000010.html",
34
37
  "doc/classes/Frivol/Config.html",
35
38
  "doc/classes/Frivol/Config.src/M000009.html",
36
39
  "doc/classes/Frivol/Config.src/M000010.html",
37
40
  "doc/classes/Frivol/Config.src/M000011.html",
41
+ "doc/classes/Frivol/Config.src/M000012.html",
42
+ "doc/classes/Frivol/Config.src/M000013.html",
38
43
  "doc/classes/Time.html",
39
44
  "doc/classes/Time.src/M000001.html",
40
45
  "doc/classes/Time.src/M000002.html",
@@ -68,16 +73,16 @@ Gem::Specification.new do |s|
68
73
 
69
74
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
70
75
  s.add_runtime_dependency(%q<json>, [">= 1.2.0"])
71
- s.add_runtime_dependency(%q<redis>, [">= 0.1.2"])
76
+ s.add_runtime_dependency(%q<redis>, [">= 2.0.10"])
72
77
  s.add_development_dependency(%q<shoulda>, [">= 2.11.1"])
73
78
  else
74
79
  s.add_dependency(%q<json>, [">= 1.2.0"])
75
- s.add_dependency(%q<redis>, [">= 0.1.2"])
80
+ s.add_dependency(%q<redis>, [">= 2.0.10"])
76
81
  s.add_dependency(%q<shoulda>, [">= 2.11.1"])
77
82
  end
78
83
  else
79
84
  s.add_dependency(%q<json>, [">= 1.2.0"])
80
- s.add_dependency(%q<redis>, [">= 0.1.2"])
85
+ s.add_dependency(%q<redis>, [">= 2.0.10"])
81
86
  s.add_dependency(%q<shoulda>, [">= 2.11.1"])
82
87
  end
83
88
  end