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
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2009 Mark Bates
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,89 @@
1
+ =What is Cachetastic?
2
+ Cachetastic is an incredibly easy to use and administer caching framework. Just because it is easy to use, does not mean that
3
+ it is light with features. Cachetastic allows you to create classes that extend <tt>Cachetastic::Cache</tt>, configure them
4
+ each individually, and much more.
5
+
6
+ Unlike other systems each cache in your system can use different backends via the use of adapters that get assigned to each
7
+ cache, and globally. You can define different expiration times, loggers, marshal methods, and more! And again, you can choose to
8
+ define these settings globally, or for each cache!
9
+
10
+ Adapters are easy to write, so if the built in adapters don't float your boat, you can easily knock one off in short order.
11
+
12
+ ==Configuration:
13
+ Configuration of Cachetastic is done using the Configatron gem. I would recommend reading the documentation on it first, http://configatron.mackframework.com, before continuing.
14
+
15
+ All configuration settings hang off of the <tt>cachetastic</tt> namespace on <tt>configatron</tt>. The default settings
16
+ all hang off the <tt>defaults</tt> namespace on the <tt>cachetastic</tt> namespace, as shown below:
17
+
18
+ # This will write detailed information to the logger.
19
+ configatron.cachetastic.defaults.debug = false
20
+
21
+ # This is the type of file store to be used for this cache.
22
+ # More adapters can be developed and plugged in as desired.
23
+ # The default is Cachetastic::Adapters::LocalMemory
24
+ configatron.cachetastic.defaults.adapter = Cachetastic::Adapters::LocalMemory
25
+ configatron.cachetastic.defaults.adapter = Cachetastic::Adapters::File
26
+ configatron.cachetastic.defaults.adapter = Cachetastic::Adapters::Memcached
27
+
28
+ # This will marshall objects into and out of the store.
29
+ # The default is :none, except for Cachetastic::Adapters::File, which defaults to :yaml
30
+ configatron.cachetastic.defaults.marshall_method = :none
31
+ configatron.cachetastic.defaults.marshall_method = :yaml
32
+ configatron.cachetastic.defaults.marshall_method = :ruby
33
+
34
+ # This sets how long objects will live in the cache before they are auto expired.
35
+ configatron.cachetastic.defaults.default_expiry = 86400 # time in seconds (default: 24 hours)
36
+
37
+ # When setting objects into the cache the expiry_swing is +/- to the expiry time.
38
+ # Example: if the expiry time is 1 minute, and the swing is 15 seconds,
39
+ # objects will go into the cache with an expiry time sometime between 45 seconds and 75 seconds.
40
+ # The default is 0 seconds.
41
+ configatron.cachetastic.defaults.expiry_swing = 15
42
+
43
+ # Configure logging for the system.
44
+ # n number of logs can be configured for a cache.
45
+ log_1 = Logger.new(STDOUT)
46
+ log_1.level = Logger::DEBUG
47
+ log_2 = Logger.new("log/cachetastic.log")
48
+ log_2.level = Logger::ERROR
49
+ configatron.cachetastic.defaults.logger = [log_1, log_2]
50
+
51
+ Overriding settings per cache is very simple. Let's take the following two caches:
52
+
53
+ class UserCache < Cachetastic::Cache
54
+ end
55
+
56
+ class Admin::UserCache < Cachetastic::Cache
57
+ end
58
+
59
+ If we wanted to set the <tt>UserCache</tt> to use the <tt>Cachetastic::Adapters::File</tt> adapter and we wanted to set the adapter for
60
+ the <tt>Admin::UserCache</tt> to use <tt>Cachetastic::Adapters::Memcached</tt>, we would configure them like such:
61
+
62
+ configatron.cachetastic.user_cache.adapter = Cachetastic::Adapters::File
63
+ configatron.cachetastic.admin.user_cache.adapter = Cachetastic::Adapters::Memcached
64
+
65
+ In this scenario we have changed the adapters for each of the classes. All of the other default settings will remain intact for
66
+ each of those classes. This makes it incredibly easy to just change the one parameter you need, and not have to reset them all.
67
+
68
+ ==Examples:
69
+
70
+ class MyAwesomeCache < Cachetastic::Cache
71
+ end
72
+
73
+ MyAwesomeCache.set(1, [1,2,3])
74
+ MyAwesomeCache.get(1) # => [1,2,3]
75
+
76
+ class MyAwesomeCache < Cachetastic::Cache
77
+ class << self
78
+ def get(key, x, y)
79
+ super(key) do
80
+ n = x + y
81
+ set(key, n)
82
+ n
83
+ end
84
+ end
85
+ end
86
+ end
87
+
88
+ MyAwesomeCache.get(1, 2, 4) # => 8
89
+ MyAwesomeCache.get(1, 4, 4) # => 8
@@ -0,0 +1,180 @@
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::Adapters</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::Adapters</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/cachetastic/adapters/base_rb.html">
59
+ lib/cachetastic/adapters/base.rb
60
+ </a>
61
+ <br />
62
+ <a href="../../files/lib/cachetastic/adapters/file_rb.html">
63
+ lib/cachetastic/adapters/file.rb
64
+ </a>
65
+ <br />
66
+ <a href="../../files/lib/cachetastic/adapters/local_memory_rb.html">
67
+ lib/cachetastic/adapters/local_memory.rb
68
+ </a>
69
+ <br />
70
+ <a href="../../files/lib/cachetastic/adapters/memcached_rb.html">
71
+ lib/cachetastic/adapters/memcached.rb
72
+ </a>
73
+ <br />
74
+ </td>
75
+ </tr>
76
+
77
+ </table>
78
+ </div>
79
+ <!-- banner header -->
80
+
81
+ <div id="bodyContent">
82
+
83
+
84
+
85
+ <div id="contextContent">
86
+
87
+
88
+
89
+ </div>
90
+
91
+ <div id="method-list">
92
+ <h3 class="section-bar">Methods</h3>
93
+
94
+ <div class="name-list">
95
+ <a href="#M000001">build</a>&nbsp;&nbsp;
96
+ </div>
97
+ </div>
98
+
99
+ </div>
100
+
101
+
102
+ <!-- if includes -->
103
+
104
+ <div id="section">
105
+
106
+ <div id="class-list">
107
+ <h3 class="section-bar">Classes and Modules</h3>
108
+
109
+ Class <a href="Adapters/Base.html" class="link">Cachetastic::Adapters::Base</a><br />
110
+ Class <a href="Adapters/File.html" class="link">Cachetastic::Adapters::File</a><br />
111
+ Class <a href="Adapters/LocalMemory.html" class="link">Cachetastic::Adapters::LocalMemory</a><br />
112
+ Class <a href="Adapters/Memcached.html" class="link">Cachetastic::Adapters::Memcached</a><br />
113
+
114
+ </div>
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+ <!-- if method_list -->
123
+ <div id="methods">
124
+ <h3 class="section-bar">Public Class methods</h3>
125
+
126
+ <div id="method-M000001" class="method-detail">
127
+ <a name="M000001"></a>
128
+
129
+ <div class="method-heading">
130
+ <a href="#M000001" class="method-signature">
131
+ <span class="method-name">build</span><span class="method-args">(klass)</span>
132
+ </a>
133
+ </div>
134
+
135
+ <div class="method-description">
136
+ <p>
137
+ This method will return the appropriate <tt><a
138
+ href="Adapters/Base.html">Cachetastic::Adapters::Base</a></tt> class that
139
+ is defined for the Class passed in. If an adapter has not been defined for
140
+ the Class than the default adapter is returned.
141
+ </p>
142
+ <p>
143
+ Examples:
144
+ </p>
145
+ <pre>
146
+ configatron.cachetastic.defaults.adapter = Cachetastic::Adapters::LocalMemory
147
+ configatron.cachetastic.user.adapter = Cachetastic::Adapters::Memcached
148
+ Cachetastic::Adapters.build(User).class # =&gt; Cachetastic::Adapters::Memcached
149
+ Cachetastic::Adapters.build(Comment).class # =&gt; Cachetastic::Adapters::LocalMemory
150
+ </pre>
151
+ <p><a class="source-toggle" href="#"
152
+ onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
153
+ <div class="method-source-code" id="M000001-source">
154
+ <pre>
155
+ <span class="ruby-comment cmt"># File lib/cachetastic/adapters/base.rb, line 16</span>
156
+ 16: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">build</span>(<span class="ruby-identifier">klass</span>)
157
+ 17: <span class="ruby-identifier">adp</span> = <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">to_configatron</span>(<span class="ruby-identifier">:cachetastic</span>).<span class="ruby-identifier">adapter</span>
158
+ 18: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">adp</span>.<span class="ruby-identifier">nil?</span>
159
+ 19: <span class="ruby-identifier">adp</span> = <span class="ruby-identifier">configatron</span>.<span class="ruby-identifier">cachetastic</span>.<span class="ruby-identifier">defaults</span>.<span class="ruby-identifier">adapter</span>
160
+ 20: <span class="ruby-keyword kw">end</span>
161
+ 21: <span class="ruby-identifier">adp</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">klass</span>)
162
+ 22: <span class="ruby-keyword kw">end</span>
163
+ </pre>
164
+ </div>
165
+ </div>
166
+ </div>
167
+
168
+
169
+ </div>
170
+
171
+
172
+ </div>
173
+
174
+
175
+ <div id="validator-badges">
176
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
177
+ </div>
178
+
179
+ </body>
180
+ </html>
@@ -0,0 +1,419 @@
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::Base</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">Cachetastic::Adapters::Base</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../../files/lib/cachetastic/adapters/base_rb.html">
59
+ lib/cachetastic/adapters/base.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ Object
69
+ </td>
70
+ </tr>
71
+ </table>
72
+ </div>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+
77
+
78
+
79
+ <div id="contextContent">
80
+
81
+ <div id="description">
82
+ <p>
83
+ This class should be extended to create <a href="Base.html#M000003">new</a>
84
+ adapters for various backends. It is important that all subclasses call the
85
+ <tt>initialize</tt> method in this base, otherwise things just will not
86
+ work right.
87
+ </p>
88
+ <p>
89
+ This base class provides common functionality and an API for all adapters
90
+ to be used with Cachetastic.
91
+ </p>
92
+ <p>
93
+ The default settings for all adapters are:
94
+ </p>
95
+ <pre>
96
+ configatron.cachetastic.defaults.marshal_method = :none
97
+ configatron.cachetastic.defaults.expiry_swing = 0
98
+ configatron.cachetastic.defaults.default_expiry = 86400
99
+ configatron.cachetastic.defaults.debug = true
100
+ configatron.cachetastic.defaults.adapter = Cachetastic::Adapters::LocalMemory
101
+ logger = ::Logger.new(File.join(FileUtils.pwd, 'log', 'cachetastic.log'))
102
+ logger.level = ::Logger::DEBUG
103
+ configatron.cachetastic.defaults.logger = logger
104
+ </pre>
105
+ <p>
106
+ See the README for more information on what each of those settings mean,
107
+ and what are values may be used for each one.
108
+ </p>
109
+
110
+ </div>
111
+
112
+
113
+ </div>
114
+
115
+ <div id="method-list">
116
+ <h3 class="section-bar">Methods</h3>
117
+
118
+ <div class="name-list">
119
+ <a href="#M000006">delete</a>&nbsp;&nbsp;
120
+ <a href="#M000007">expire_all</a>&nbsp;&nbsp;
121
+ <a href="#M000004">get</a>&nbsp;&nbsp;
122
+ <a href="#M000003">new</a>&nbsp;&nbsp;
123
+ <a href="#M000005">set</a>&nbsp;&nbsp;
124
+ <a href="#M000008">transform_key</a>&nbsp;&nbsp;
125
+ <a href="#M000009">valid?</a>&nbsp;&nbsp;
126
+ </div>
127
+ </div>
128
+
129
+ </div>
130
+
131
+
132
+ <!-- if includes -->
133
+
134
+ <div id="section">
135
+
136
+
137
+
138
+
139
+
140
+ <div id="attribute-list">
141
+ <h3 class="section-bar">Attributes</h3>
142
+
143
+ <div class="name-list">
144
+ <table>
145
+ <tr class="top-aligned-row context-row">
146
+ <td class="context-item-name">klass</td>
147
+ <td class="context-item-value">&nbsp;[RW]&nbsp;</td>
148
+ <td class="context-item-desc">
149
+ The Class that this adapter is associated with. Note that it is a
150
+ <em>class</em> reference and not an instance reference.
151
+
152
+ </td>
153
+ </tr>
154
+ </table>
155
+ </div>
156
+ </div>
157
+
158
+
159
+
160
+ <!-- if method_list -->
161
+ <div id="methods">
162
+ <h3 class="section-bar">Public Class methods</h3>
163
+
164
+ <div id="method-M000003" class="method-detail">
165
+ <a name="M000003"></a>
166
+
167
+ <div class="method-heading">
168
+ <a href="#M000003" class="method-signature">
169
+ <span class="method-name">new</span><span class="method-args">(klass)</span>
170
+ </a>
171
+ </div>
172
+
173
+ <div class="method-description">
174
+ <p>
175
+ Creates a <a href="Base.html#M000003">new</a> adapter. It takes a class
176
+ reference to tie the instance of the adapter to a particular class. Note
177
+ that it is a <em>class</em> reference and not an instance reference.
178
+ </p>
179
+ <p>
180
+ Examples:
181
+ </p>
182
+ <pre>
183
+ Cachetastic::Adapters::Base.new(User)
184
+ </pre>
185
+ <p>
186
+ <a href="../Adapters.html">Adapters</a> are configured using the
187
+ Configatron gem.
188
+ </p>
189
+ <p>
190
+ Examples:
191
+ </p>
192
+ <pre>
193
+ configatron.cachetastic.user.adapter = Cachetastic::Adapters::File
194
+ configatron.cachetastic.user.expiry_time = 5.hours
195
+ configatron.cachetastic.defaults.expiry_time = 24.hours
196
+ </pre>
197
+ <p>
198
+ Refered to each adapter for its specific configuration settings.
199
+ </p>
200
+ <p><a class="source-toggle" href="#"
201
+ onclick="toggleCode('M000003-source');return false;">[Source]</a></p>
202
+ <div class="method-source-code" id="M000003-source">
203
+ <pre>
204
+ <span class="ruby-comment cmt"># File lib/cachetastic/adapters/base.rb, line 67</span>
205
+ 67: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">klass</span>)
206
+ 68: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">klass</span> = <span class="ruby-identifier">klass</span>
207
+ 69: <span class="ruby-identifier">configatron</span>.<span class="ruby-identifier">cachetastic</span>.<span class="ruby-identifier">defaults</span>.<span class="ruby-identifier">configatron_keys</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-operator">|</span>
208
+ 70: <span class="ruby-identifier">define_accessor</span>(<span class="ruby-identifier">key</span>)
209
+ 71: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-node">&quot;#{key}=&quot;</span>, <span class="ruby-identifier">configatron</span>.<span class="ruby-identifier">cachetastic</span>.<span class="ruby-identifier">defaults</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">key</span>))
210
+ 72: <span class="ruby-keyword kw">end</span>
211
+ 73: <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">to_configatron</span>(<span class="ruby-identifier">:cachetastic</span>).<span class="ruby-identifier">configatron_keys</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-operator">|</span>
212
+ 74: <span class="ruby-identifier">define_accessor</span>(<span class="ruby-identifier">key</span>)
213
+ 75: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-node">&quot;#{key}=&quot;</span>, <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">to_configatron</span>(<span class="ruby-identifier">:cachetastic</span>).<span class="ruby-identifier">send</span>(<span class="ruby-identifier">key</span>))
214
+ 76: <span class="ruby-keyword kw">end</span>
215
+ 77: <span class="ruby-keyword kw">end</span>
216
+ </pre>
217
+ </div>
218
+ </div>
219
+ </div>
220
+
221
+ <h3 class="section-bar">Public Instance methods</h3>
222
+
223
+ <div id="method-M000006" class="method-detail">
224
+ <a name="M000006"></a>
225
+
226
+ <div class="method-heading">
227
+ <a href="#M000006" class="method-signature">
228
+ <span class="method-name">delete</span><span class="method-args">(key)</span>
229
+ </a>
230
+ </div>
231
+
232
+ <div class="method-description">
233
+ <p>
234
+ <b>This method MUST be implemented by a subclass!</b>
235
+ </p>
236
+ <p>
237
+ The implementation of this method should take a key and remove an object,
238
+ if it exists, from an underlying persistence store.
239
+ </p>
240
+ <p><a class="source-toggle" href="#"
241
+ onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
242
+ <div class="method-source-code" id="M000006-source">
243
+ <pre>
244
+ <span class="ruby-comment cmt"># File lib/cachetastic/adapters/base.rb, line 101</span>
245
+ 101: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">delete</span>(<span class="ruby-identifier">key</span>)
246
+ 102: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NoMethodError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'delete'</span>)
247
+ 103: <span class="ruby-keyword kw">end</span>
248
+ </pre>
249
+ </div>
250
+ </div>
251
+ </div>
252
+
253
+ <div id="method-M000007" class="method-detail">
254
+ <a name="M000007"></a>
255
+
256
+ <div class="method-heading">
257
+ <a href="#M000007" class="method-signature">
258
+ <span class="method-name">expire_all</span><span class="method-args">()</span>
259
+ </a>
260
+ </div>
261
+
262
+ <div class="method-description">
263
+ <p>
264
+ <b>This method MUST be implemented by a subclass!</b>
265
+ </p>
266
+ <p>
267
+ The implementation of this method is expected to <a
268
+ href="Base.html#M000006">delete</a> all objects belonging to the associated
269
+ cache from the underlying persistence store. It is <b>NOT</b> meant to <a
270
+ href="Base.html#M000006">delete</a> <b>ALL</b> objects across <b>ALL</b>
271
+ caches for the underlying persistence store. That would be very very bad!!
272
+ </p>
273
+ <p><a class="source-toggle" href="#"
274
+ onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
275
+ <div class="method-source-code" id="M000007-source">
276
+ <pre>
277
+ <span class="ruby-comment cmt"># File lib/cachetastic/adapters/base.rb, line 112</span>
278
+ 112: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">expire_all</span>
279
+ 113: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NoMethodError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'expire_all'</span>)
280
+ 114: <span class="ruby-keyword kw">end</span>
281
+ </pre>
282
+ </div>
283
+ </div>
284
+ </div>
285
+
286
+ <div id="method-M000004" class="method-detail">
287
+ <a name="M000004"></a>
288
+
289
+ <div class="method-heading">
290
+ <a href="#M000004" class="method-signature">
291
+ <span class="method-name">get</span><span class="method-args">(key)</span>
292
+ </a>
293
+ </div>
294
+
295
+ <div class="method-description">
296
+ <p>
297
+ <b>This method MUST be implemented by a subclass!</b>
298
+ </p>
299
+ <p>
300
+ The implementation of this method should take a key and return an
301
+ associated object, if available, from the underlying persistence layer.
302
+ </p>
303
+ <p><a class="source-toggle" href="#"
304
+ onclick="toggleCode('M000004-source');return false;">[Source]</a></p>
305
+ <div class="method-source-code" id="M000004-source">
306
+ <pre>
307
+ <span class="ruby-comment cmt"># File lib/cachetastic/adapters/base.rb, line 84</span>
308
+ 84: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get</span>(<span class="ruby-identifier">key</span>)
309
+ 85: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NoMethodError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'get'</span>)
310
+ 86: <span class="ruby-keyword kw">end</span>
311
+ </pre>
312
+ </div>
313
+ </div>
314
+ </div>
315
+
316
+ <div id="method-M000005" class="method-detail">
317
+ <a name="M000005"></a>
318
+
319
+ <div class="method-heading">
320
+ <a href="#M000005" class="method-signature">
321
+ <span class="method-name">set</span><span class="method-args">(key, value, expiry_time = configatron.cachetastic.defaults.default_expiry)</span>
322
+ </a>
323
+ </div>
324
+
325
+ <div class="method-description">
326
+ <p>
327
+ <b>This method MUST be implemented by a subclass!</b>
328
+ </p>
329
+ <p>
330
+ The implementation of this method should take a key, a value, and an expiry
331
+ time and save it to the persistence store, where it should live until it is
332
+ either deleted by the user of the expiry time has passed.
333
+ </p>
334
+ <p><a class="source-toggle" href="#"
335
+ onclick="toggleCode('M000005-source');return false;">[Source]</a></p>
336
+ <div class="method-source-code" id="M000005-source">
337
+ <pre>
338
+ <span class="ruby-comment cmt"># File lib/cachetastic/adapters/base.rb, line 93</span>
339
+ 93: <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_time</span> = <span class="ruby-identifier">configatron</span>.<span class="ruby-identifier">cachetastic</span>.<span class="ruby-identifier">defaults</span>.<span class="ruby-identifier">default_expiry</span>)
340
+ 94: <span class="ruby-identifier">raise</span> <span class="ruby-constant">NoMethodError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'set'</span>)
341
+ 95: <span class="ruby-keyword kw">end</span>
342
+ </pre>
343
+ </div>
344
+ </div>
345
+ </div>
346
+
347
+ <div id="method-M000008" class="method-detail">
348
+ <a name="M000008"></a>
349
+
350
+ <div class="method-heading">
351
+ <a href="#M000008" class="method-signature">
352
+ <span class="method-name">transform_key</span><span class="method-args">(key)</span>
353
+ </a>
354
+ </div>
355
+
356
+ <div class="method-description">
357
+ <p>
358
+ Allows an adapter to transform the key to a safe representation for
359
+ it&#8216;s backend. For example, the key: &#8217;$*&#8230;123()%~q&#8217;
360
+ is not a key for the file system, so the <a
361
+ href="File.html">Cachetastic::Adapters::File</a> class should override this
362
+ to make it safe for the file system.
363
+ </p>
364
+ <p><a class="source-toggle" href="#"
365
+ onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
366
+ <div class="method-source-code" id="M000008-source">
367
+ <pre>
368
+ <span class="ruby-comment cmt"># File lib/cachetastic/adapters/base.rb, line 122</span>
369
+ 122: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">transform_key</span>(<span class="ruby-identifier">key</span>)
370
+ 123: <span class="ruby-identifier">key</span>
371
+ 124: <span class="ruby-keyword kw">end</span>
372
+ </pre>
373
+ </div>
374
+ </div>
375
+ </div>
376
+
377
+ <div id="method-M000009" class="method-detail">
378
+ <a name="M000009"></a>
379
+
380
+ <div class="method-heading">
381
+ <a href="#M000009" class="method-signature">
382
+ <span class="method-name">valid?</span><span class="method-args">()</span>
383
+ </a>
384
+ </div>
385
+
386
+ <div class="method-description">
387
+ <p>
388
+ <b>This method MUST be implemented by a subclass!</b>
389
+ </p>
390
+ <p>
391
+ The implementation of this method should return <tt>true</tt> if the
392
+ adapter is in a valid state, and <tt>false</tt> if it is not.
393
+ </p>
394
+ <p><a class="source-toggle" href="#"
395
+ onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
396
+ <div class="method-source-code" id="M000009-source">
397
+ <pre>
398
+ <span class="ruby-comment cmt"># File lib/cachetastic/adapters/base.rb, line 131</span>
399
+ 131: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">valid?</span>
400
+ 132: <span class="ruby-keyword kw">true</span>
401
+ 133: <span class="ruby-keyword kw">end</span>
402
+ </pre>
403
+ </div>
404
+ </div>
405
+ </div>
406
+
407
+
408
+ </div>
409
+
410
+
411
+ </div>
412
+
413
+
414
+ <div id="validator-badges">
415
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
416
+ </div>
417
+
418
+ </body>
419
+ </html>