cachetastic-three 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +21 -0
- data/README +89 -0
- data/doc/classes/Cachetastic/Adapters.html +180 -0
- data/doc/classes/Cachetastic/Adapters/Base.html +419 -0
- data/doc/classes/Cachetastic/Adapters/File.html +135 -0
- data/doc/classes/Cachetastic/Adapters/LocalMemory.html +125 -0
- data/doc/classes/Cachetastic/Adapters/Memcached.html +193 -0
- data/doc/classes/Cachetastic/Cache.html +425 -0
- data/doc/classes/Cachetastic/Cacheable.html +255 -0
- data/doc/classes/Cachetastic/Cacheable/ClassAndInstanceMethods.html +290 -0
- data/doc/classes/Cachetastic/Cacheable/ClassOnlyMethods.html +197 -0
- data/doc/classes/Cachetastic/Logger.html +186 -0
- data/doc/created.rid +1 -0
- data/doc/files/LICENSE.html +132 -0
- data/doc/files/README.html +222 -0
- data/doc/files/lib/cachetastic/adapters/base_rb.html +101 -0
- data/doc/files/lib/cachetastic/adapters/file_rb.html +101 -0
- data/doc/files/lib/cachetastic/adapters/local_memory_rb.html +101 -0
- data/doc/files/lib/cachetastic/adapters/memcached_rb.html +101 -0
- data/doc/files/lib/cachetastic/cache_rb.html +101 -0
- data/doc/files/lib/cachetastic/cacheable_rb.html +101 -0
- data/doc/files/lib/cachetastic/extensions/string_rb.html +108 -0
- data/doc/files/lib/cachetastic/logger_rb.html +101 -0
- data/doc/files/lib/cachetastic/store_object_rb.html +101 -0
- data/doc/files/lib/cachetastic_rb.html +112 -0
- data/doc/fr_class_index.html +36 -0
- data/doc/fr_file_index.html +38 -0
- data/doc/fr_method_index.html +52 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/lib/cachetastic.rb +20 -0
- data/lib/cachetastic/adapters/base.rb +178 -0
- data/lib/cachetastic/adapters/file.rb +66 -0
- data/lib/cachetastic/adapters/local_memory.rb +37 -0
- data/lib/cachetastic/adapters/memcached.rb +114 -0
- data/lib/cachetastic/cache.rb +165 -0
- data/lib/cachetastic/cacheable.rb +202 -0
- data/lib/cachetastic/extensions/string.rb +8 -0
- data/lib/cachetastic/logger.rb +49 -0
- data/lib/cachetastic/store_object.rb +22 -0
- metadata +122 -0
@@ -0,0 +1,186 @@
|
|
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::Logger</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::Logger</td>
|
54
|
+
</tr>
|
55
|
+
<tr class="top-aligned-row">
|
56
|
+
<td><strong>In:</strong></td>
|
57
|
+
<td>
|
58
|
+
<a href="../../files/lib/cachetastic/logger_rb.html">
|
59
|
+
lib/cachetastic/logger.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 handles logging for the caches and their adapters. This class
|
84
|
+
exists simply to supply the ability to write to multiple loggers
|
85
|
+
simultaneously from a single call. It also creates a standardized message
|
86
|
+
to write to those loggers.
|
87
|
+
</p>
|
88
|
+
<p>
|
89
|
+
It is important that any logger type of class you decide to use reponds to
|
90
|
+
the following methods:
|
91
|
+
</p>
|
92
|
+
<pre>
|
93
|
+
fatal(message)
|
94
|
+
error(message)
|
95
|
+
warn(message)
|
96
|
+
info(message)
|
97
|
+
debug(message)
|
98
|
+
</pre>
|
99
|
+
|
100
|
+
</div>
|
101
|
+
|
102
|
+
|
103
|
+
</div>
|
104
|
+
|
105
|
+
<div id="method-list">
|
106
|
+
<h3 class="section-bar">Methods</h3>
|
107
|
+
|
108
|
+
<div class="name-list">
|
109
|
+
<a href="#M000026">new</a>
|
110
|
+
</div>
|
111
|
+
</div>
|
112
|
+
|
113
|
+
</div>
|
114
|
+
|
115
|
+
|
116
|
+
<!-- if includes -->
|
117
|
+
|
118
|
+
<div id="section">
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
<div id="attribute-list">
|
125
|
+
<h3 class="section-bar">Attributes</h3>
|
126
|
+
|
127
|
+
<div class="name-list">
|
128
|
+
<table>
|
129
|
+
<tr class="top-aligned-row context-row">
|
130
|
+
<td class="context-item-name">loggers</td>
|
131
|
+
<td class="context-item-value"> [RW] </td>
|
132
|
+
<td class="context-item-desc">
|
133
|
+
An <tt>Array</tt> of ‘real’ loggers to write to.
|
134
|
+
|
135
|
+
</td>
|
136
|
+
</tr>
|
137
|
+
</table>
|
138
|
+
</div>
|
139
|
+
</div>
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
<!-- if method_list -->
|
144
|
+
<div id="methods">
|
145
|
+
<h3 class="section-bar">Public Class methods</h3>
|
146
|
+
|
147
|
+
<div id="method-M000026" class="method-detail">
|
148
|
+
<a name="M000026"></a>
|
149
|
+
|
150
|
+
<div class="method-heading">
|
151
|
+
<a href="#M000026" class="method-signature">
|
152
|
+
<span class="method-name">new</span><span class="method-args">(*loggers)</span>
|
153
|
+
</a>
|
154
|
+
</div>
|
155
|
+
|
156
|
+
<div class="method-description">
|
157
|
+
<p>
|
158
|
+
The <tt>initialize</tt> method takes an <tt>Array</tt> of your favorite
|
159
|
+
logger style classes to write to.
|
160
|
+
</p>
|
161
|
+
<p><a class="source-toggle" href="#"
|
162
|
+
onclick="toggleCode('M000026-source');return false;">[Source]</a></p>
|
163
|
+
<div class="method-source-code" id="M000026-source">
|
164
|
+
<pre>
|
165
|
+
<span class="ruby-comment cmt"># File lib/cachetastic/logger.rb, line 21</span>
|
166
|
+
21: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">loggers</span>)
|
167
|
+
22: <span class="ruby-ivar">@loggers</span> = [<span class="ruby-identifier">loggers</span>].<span class="ruby-identifier">flatten</span>
|
168
|
+
23: <span class="ruby-keyword kw">end</span>
|
169
|
+
</pre>
|
170
|
+
</div>
|
171
|
+
</div>
|
172
|
+
</div>
|
173
|
+
|
174
|
+
|
175
|
+
</div>
|
176
|
+
|
177
|
+
|
178
|
+
</div>
|
179
|
+
|
180
|
+
|
181
|
+
<div id="validator-badges">
|
182
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
183
|
+
</div>
|
184
|
+
|
185
|
+
</body>
|
186
|
+
</html>
|
data/doc/created.rid
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Thu, 11 Jun 2009 14:18:18 -0400
|
@@ -0,0 +1,132 @@
|
|
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>File: LICENSE</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="fileHeader">
|
50
|
+
<h1>LICENSE</h1>
|
51
|
+
<table class="header-table">
|
52
|
+
<tr class="top-aligned-row">
|
53
|
+
<td><strong>Path:</strong></td>
|
54
|
+
<td>LICENSE
|
55
|
+
</td>
|
56
|
+
</tr>
|
57
|
+
<tr class="top-aligned-row">
|
58
|
+
<td><strong>Last Update:</strong></td>
|
59
|
+
<td>Fri Jun 05 17:12:05 -0400 2009</td>
|
60
|
+
</tr>
|
61
|
+
</table>
|
62
|
+
</div>
|
63
|
+
<!-- banner header -->
|
64
|
+
|
65
|
+
<div id="bodyContent">
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
<div id="contextContent">
|
70
|
+
|
71
|
+
<div id="description">
|
72
|
+
<p>
|
73
|
+
The MIT License
|
74
|
+
</p>
|
75
|
+
<p>
|
76
|
+
Copyright (c) 2009 Mark Bates
|
77
|
+
</p>
|
78
|
+
<p>
|
79
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
80
|
+
copy of this software and associated documentation files (the
|
81
|
+
"Software"), to deal in the Software without restriction,
|
82
|
+
including without limitation the rights to use, copy, modify, merge,
|
83
|
+
publish, distribute, sublicense, and/or sell copies of the Software, and to
|
84
|
+
permit persons to whom the Software is furnished to do so, subject to the
|
85
|
+
following conditions:
|
86
|
+
</p>
|
87
|
+
<p>
|
88
|
+
The above copyright notice and this permission notice shall be included in
|
89
|
+
all copies or substantial portions of the Software.
|
90
|
+
</p>
|
91
|
+
<p>
|
92
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
93
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
94
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
95
|
+
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
96
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
97
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
98
|
+
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
99
|
+
</p>
|
100
|
+
|
101
|
+
</div>
|
102
|
+
|
103
|
+
|
104
|
+
</div>
|
105
|
+
|
106
|
+
|
107
|
+
</div>
|
108
|
+
|
109
|
+
|
110
|
+
<!-- if includes -->
|
111
|
+
|
112
|
+
<div id="section">
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
<!-- if method_list -->
|
122
|
+
|
123
|
+
|
124
|
+
</div>
|
125
|
+
|
126
|
+
|
127
|
+
<div id="validator-badges">
|
128
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
129
|
+
</div>
|
130
|
+
|
131
|
+
</body>
|
132
|
+
</html>
|
@@ -0,0 +1,222 @@
|
|
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>File: README</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="fileHeader">
|
50
|
+
<h1>README</h1>
|
51
|
+
<table class="header-table">
|
52
|
+
<tr class="top-aligned-row">
|
53
|
+
<td><strong>Path:</strong></td>
|
54
|
+
<td>README
|
55
|
+
</td>
|
56
|
+
</tr>
|
57
|
+
<tr class="top-aligned-row">
|
58
|
+
<td><strong>Last Update:</strong></td>
|
59
|
+
<td>Fri Jun 05 17:11:09 -0400 2009</td>
|
60
|
+
</tr>
|
61
|
+
</table>
|
62
|
+
</div>
|
63
|
+
<!-- banner header -->
|
64
|
+
|
65
|
+
<div id="bodyContent">
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
<div id="contextContent">
|
70
|
+
|
71
|
+
<div id="description">
|
72
|
+
<h1>What is Cachetastic?</h1>
|
73
|
+
<p>
|
74
|
+
Cachetastic is an incredibly easy to use and administer caching framework.
|
75
|
+
Just because it is easy to use, does not mean that it is light with
|
76
|
+
features. Cachetastic allows you to create classes that extend <tt><a
|
77
|
+
href="../classes/Cachetastic/Cache.html">Cachetastic::Cache</a></tt>,
|
78
|
+
configure them each individually, and much more.
|
79
|
+
</p>
|
80
|
+
<p>
|
81
|
+
Unlike other systems each cache in your system can use different backends
|
82
|
+
via the use of adapters that get assigned to each cache, and globally. You
|
83
|
+
can define different expiration times, loggers, marshal methods, and more!
|
84
|
+
And again, you can choose to define these settings globally, or for each
|
85
|
+
cache!
|
86
|
+
</p>
|
87
|
+
<p>
|
88
|
+
Adapters are easy to write, so if the built in adapters don‘t float
|
89
|
+
your boat, you can easily knock one off in short order.
|
90
|
+
</p>
|
91
|
+
<h2>Configuration:</h2>
|
92
|
+
<p>
|
93
|
+
Configuration of Cachetastic is done using the Configatron gem. I would
|
94
|
+
recommend reading the documentation on it first, <a
|
95
|
+
href="http://configatron.mackframework.com">configatron.mackframework.com</a>,
|
96
|
+
before continuing.
|
97
|
+
</p>
|
98
|
+
<p>
|
99
|
+
All configuration settings hang off of the <tt>cachetastic</tt> namespace
|
100
|
+
on <tt>configatron</tt>. The default settings all hang off the
|
101
|
+
<tt>defaults</tt> namespace on the <tt>cachetastic</tt> namespace, as shown
|
102
|
+
below:
|
103
|
+
</p>
|
104
|
+
<pre>
|
105
|
+
# This will write detailed information to the logger.
|
106
|
+
configatron.cachetastic.defaults.debug = false
|
107
|
+
|
108
|
+
# This is the type of file store to be used for this cache.
|
109
|
+
# More adapters can be developed and plugged in as desired.
|
110
|
+
# The default is Cachetastic::Adapters::LocalMemory
|
111
|
+
configatron.cachetastic.defaults.adapter = Cachetastic::Adapters::LocalMemory
|
112
|
+
configatron.cachetastic.defaults.adapter = Cachetastic::Adapters::File
|
113
|
+
configatron.cachetastic.defaults.adapter = Cachetastic::Adapters::Memcached
|
114
|
+
|
115
|
+
# This will marshall objects into and out of the store.
|
116
|
+
# The default is :none, except for Cachetastic::Adapters::File, which defaults to :yaml
|
117
|
+
configatron.cachetastic.defaults.marshall_method = :none
|
118
|
+
configatron.cachetastic.defaults.marshall_method = :yaml
|
119
|
+
configatron.cachetastic.defaults.marshall_method = :ruby
|
120
|
+
|
121
|
+
# This sets how long objects will live in the cache before they are auto expired.
|
122
|
+
configatron.cachetastic.defaults.default_expiry = 86400 # time in seconds (default: 24 hours)
|
123
|
+
|
124
|
+
# When setting objects into the cache the expiry_swing is +/- to the expiry time.
|
125
|
+
# Example: if the expiry time is 1 minute, and the swing is 15 seconds,
|
126
|
+
# objects will go into the cache with an expiry time sometime between 45 seconds and 75 seconds.
|
127
|
+
# The default is 0 seconds.
|
128
|
+
configatron.cachetastic.defaults.expiry_swing = 15
|
129
|
+
|
130
|
+
# Configure logging for the system.
|
131
|
+
# n number of logs can be configured for a cache.
|
132
|
+
log_1 = Logger.new(STDOUT)
|
133
|
+
log_1.level = Logger::DEBUG
|
134
|
+
log_2 = Logger.new("log/cachetastic.log")
|
135
|
+
log_2.level = Logger::ERROR
|
136
|
+
configatron.cachetastic.defaults.logger = [log_1, log_2]
|
137
|
+
</pre>
|
138
|
+
<p>
|
139
|
+
Overriding settings per cache is very simple. Let‘s take the
|
140
|
+
following two caches:
|
141
|
+
</p>
|
142
|
+
<pre>
|
143
|
+
class UserCache < Cachetastic::Cache
|
144
|
+
end
|
145
|
+
|
146
|
+
class Admin::UserCache < Cachetastic::Cache
|
147
|
+
end
|
148
|
+
</pre>
|
149
|
+
<p>
|
150
|
+
If we wanted to set the <tt>UserCache</tt> to use the <tt><a
|
151
|
+
href="../classes/Cachetastic/Adapters/File.html">Cachetastic::Adapters::File</a></tt>
|
152
|
+
adapter and we wanted to set the adapter for the <tt>Admin::UserCache</tt>
|
153
|
+
to use <tt><a
|
154
|
+
href="../classes/Cachetastic/Adapters/Memcached.html">Cachetastic::Adapters::Memcached</a></tt>,
|
155
|
+
we would configure them like such:
|
156
|
+
</p>
|
157
|
+
<pre>
|
158
|
+
configatron.cachetastic.user_cache.adapter = Cachetastic::Adapters::File
|
159
|
+
configatron.cachetastic.admin.user_cache.adapter = Cachetastic::Adapters::Memcached
|
160
|
+
</pre>
|
161
|
+
<p>
|
162
|
+
In this scenario we have changed the adapters for each of the classes. All
|
163
|
+
of the other default settings will remain intact for each of those classes.
|
164
|
+
This makes it incredibly easy to just change the one parameter you need,
|
165
|
+
and not have to reset them all.
|
166
|
+
</p>
|
167
|
+
<h2>Examples:</h2>
|
168
|
+
<pre>
|
169
|
+
class MyAwesomeCache < Cachetastic::Cache
|
170
|
+
end
|
171
|
+
|
172
|
+
MyAwesomeCache.set(1, [1,2,3])
|
173
|
+
MyAwesomeCache.get(1) # => [1,2,3]
|
174
|
+
|
175
|
+
class MyAwesomeCache < Cachetastic::Cache
|
176
|
+
class << self
|
177
|
+
def get(key, x, y)
|
178
|
+
super(key) do
|
179
|
+
n = x + y
|
180
|
+
set(key, n)
|
181
|
+
n
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
MyAwesomeCache.get(1, 2, 4) # => 8
|
188
|
+
MyAwesomeCache.get(1, 4, 4) # => 8
|
189
|
+
</pre>
|
190
|
+
|
191
|
+
</div>
|
192
|
+
|
193
|
+
|
194
|
+
</div>
|
195
|
+
|
196
|
+
|
197
|
+
</div>
|
198
|
+
|
199
|
+
|
200
|
+
<!-- if includes -->
|
201
|
+
|
202
|
+
<div id="section">
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
<!-- if method_list -->
|
212
|
+
|
213
|
+
|
214
|
+
</div>
|
215
|
+
|
216
|
+
|
217
|
+
<div id="validator-badges">
|
218
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
219
|
+
</div>
|
220
|
+
|
221
|
+
</body>
|
222
|
+
</html>
|