cachetastic 2.1.4 → 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 +57 -43
- data/doc/classes/Cachetastic/Adapters.html +180 -0
- data/doc/classes/Cachetastic/Adapters/Base.html +206 -123
- data/doc/classes/Cachetastic/Adapters/File.html +17 -130
- data/doc/classes/Cachetastic/Adapters/LocalMemory.html +7 -228
- data/doc/classes/Cachetastic/Adapters/Memcached.html +193 -0
- data/doc/classes/Cachetastic/Cache.html +425 -0
- data/doc/classes/Cachetastic/Cacheable.html +26 -30
- data/doc/classes/Cachetastic/Cacheable/ClassAndInstanceMethods.html +66 -62
- data/doc/classes/Cachetastic/Cacheable/ClassOnlyMethods.html +30 -30
- data/doc/classes/Cachetastic/Logger.html +31 -33
- data/doc/created.rid +1 -1
- data/doc/files/{lib/cachetastic/adapters/html_file_rb.html → LICENSE.html} +29 -34
- data/doc/files/README.html +91 -57
- data/doc/files/lib/cachetastic/adapters/base_rb.html +1 -39
- data/doc/files/lib/cachetastic/adapters/file_rb.html +1 -21
- data/doc/files/lib/cachetastic/adapters/local_memory_rb.html +1 -9
- data/doc/files/lib/cachetastic/{ruby_extensions/kernel_rb.html → adapters/memcached_rb.html} +4 -4
- data/doc/files/lib/cachetastic/{ruby_extensions/string_rb.html → cache_rb.html} +5 -5
- data/doc/files/lib/cachetastic/cacheable_rb.html +1 -1
- data/doc/files/lib/cachetastic/{caches/base_rb.html → extensions/string_rb.html} +5 -5
- data/doc/files/lib/cachetastic/logger_rb.html +1 -7
- data/doc/files/lib/cachetastic/{adapters/store_object_rb.html → store_object_rb.html} +3 -3
- data/doc/files/lib/cachetastic_rb.html +4 -95
- data/doc/fr_class_index.html +3 -15
- data/doc/fr_file_index.html +5 -16
- data/doc/fr_method_index.html +26 -78
- data/lib/cachetastic.rb +16 -70
- data/lib/cachetastic/adapters/base.rb +178 -76
- data/lib/cachetastic/adapters/file.rb +63 -46
- data/lib/cachetastic/adapters/local_memory.rb +36 -67
- data/lib/cachetastic/adapters/memcached.rb +114 -0
- data/lib/cachetastic/cache.rb +165 -0
- data/lib/cachetastic/cacheable.rb +19 -15
- data/lib/cachetastic/extensions/string.rb +8 -0
- data/lib/cachetastic/logger.rb +41 -41
- data/lib/cachetastic/store_object.rb +22 -0
- metadata +43 -64
- data/bin/cachetastic_drb_server +0 -115
- data/doc/classes/ActiveRecord/Base.html +0 -194
- data/doc/classes/CGI/Session/CachetasticStore.html +0 -124
- data/doc/classes/Cachetastic/Adapters/Drb.html +0 -332
- data/doc/classes/Cachetastic/Adapters/FileBase.html +0 -309
- data/doc/classes/Cachetastic/Adapters/HtmlFile.html +0 -224
- data/doc/classes/Cachetastic/Adapters/Memcache.html +0 -498
- data/doc/classes/Cachetastic/Caches/Base.html +0 -643
- data/doc/classes/Cachetastic/Caches/Base/RegisteredCaches.html +0 -179
- data/doc/classes/Cachetastic/Caches/MackSessionCache.html +0 -119
- data/doc/classes/Cachetastic/Caches/PageCache.html +0 -121
- data/doc/classes/Cachetastic/Caches/RailsSessionCache.html +0 -154
- data/doc/classes/Cachetastic/Connection.html +0 -212
- data/doc/classes/Cachetastic/Errors/UnsupportedAdapter.html +0 -146
- data/doc/classes/Object.html +0 -222
- data/doc/classes/String.html +0 -172
- data/doc/files/lib/cachetastic/adapters/drb_rb.html +0 -115
- data/doc/files/lib/cachetastic/adapters/file_base_rb.html +0 -109
- data/doc/files/lib/cachetastic/adapters/memcache_rb.html +0 -127
- data/doc/files/lib/cachetastic/caches/mack_session_cache_rb.html +0 -107
- data/doc/files/lib/cachetastic/caches/page_cache_rb.html +0 -109
- data/doc/files/lib/cachetastic/caches/rails_session_cache_rb.html +0 -107
- data/doc/files/lib/cachetastic/connection_rb.html +0 -107
- data/doc/files/lib/cachetastic/errors/unsupported_adapter_rb.html +0 -101
- data/doc/files/lib/cachetastic/rails_extensions/active_record_base_rb.html +0 -101
- data/doc/files/lib/cachetastic/rails_extensions/cgi_session_store_rb.html +0 -109
- data/doc/files/lib/cachetastic/ruby_extensions/object_rb.html +0 -101
- data/lib/cachetastic/adapters/drb.rb +0 -51
- data/lib/cachetastic/adapters/file_base.rb +0 -86
- data/lib/cachetastic/adapters/html_file.rb +0 -68
- data/lib/cachetastic/adapters/memcache.rb +0 -114
- data/lib/cachetastic/adapters/store_object.rb +0 -28
- data/lib/cachetastic/caches/base.rb +0 -238
- data/lib/cachetastic/caches/mack_session_cache.rb +0 -3
- data/lib/cachetastic/caches/page_cache.rb +0 -6
- data/lib/cachetastic/caches/rails_session_cache.rb +0 -12
- data/lib/cachetastic/connection.rb +0 -24
- data/lib/cachetastic/errors/unsupported_adapter.rb +0 -7
- data/lib/cachetastic/rails_extensions/active_record_base.rb +0 -24
- data/lib/cachetastic/rails_extensions/cgi_session_store.rb +0 -59
- data/lib/cachetastic/ruby_extensions/kernel.rb +0 -25
- data/lib/cachetastic/ruby_extensions/object.rb +0 -22
- data/lib/cachetastic/ruby_extensions/string.rb +0 -15
- data/test/active_record_test.rb +0 -89
- data/test/cacheable_test.rb +0 -88
- data/test/cachetastic_unit_test.rb +0 -74
- data/test/config.rb +0 -30
- data/test/drb_adapter_test.rb +0 -14
- data/test/file_adapter_test.rb +0 -49
- data/test/memcache_adapter_test.rb +0 -18
- data/test/test_helper.rb +0 -75
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>
|
59
|
+
<td>Thu Jun 11 12:07:40 -0400 2009</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -68,106 +68,15 @@
|
|
68
68
|
|
69
69
|
<div id="contextContent">
|
70
70
|
|
71
|
-
<div id="description">
|
72
|
-
<h1>Configuration:</h1>
|
73
|
-
<pre>
|
74
|
-
# this will dump into the log, configuration info for each cache, as well as the .inspect
|
75
|
-
# for each object returned from the cache
|
76
|
-
configatron.cachetastic_default_options.debug = false
|
77
|
-
|
78
|
-
# this is the type of file store to be used for this cache.
|
79
|
-
# more adapters can be developed and plugged in as desired
|
80
|
-
configatron.cachetastic_default_options.adapter = :local_memory # local_memory | memcache | file | drb | html_file (default: local_memory)
|
81
|
-
|
82
|
-
# this will marshall objects into and out of the store.
|
83
|
-
configatron.cachetastic_default_options.marshall_method = :none # none | yaml | ruby (default: none)
|
84
|
-
|
85
|
-
# this sets how long objects will live in the cache before they are auto expired.
|
86
|
-
configatron.cachetastic_default_options.default_expiry = 86400 # time in seconds (default: 24 hours)
|
87
|
-
|
88
|
-
# when setting objects into the cache the expiry_swing is +/- to the expiry time.
|
89
|
-
# example: if the expiry time is 1 hour, and the swing is 15 minutes,
|
90
|
-
# objects will go into the cache with an expiry time sometime between 45 mins and 75 mins.
|
91
|
-
configatron.cachetastic_default_options.expiry_swing = 60 * 15 # time in seconds (default: 0)
|
92
|
-
|
93
|
-
# these options get passed on directly to the store.
|
94
|
-
# listed below are options for memcache:
|
95
|
-
configatron.cachetastic_default_options.store_options.c_threshold = "10_000"
|
96
|
-
configatron.cachetastic_default_options.store_options.compression = true
|
97
|
-
configatron.cachetastic_default_options.store_options.debug = false
|
98
|
-
configatron.cachetastic_default_options.store_options.readonly = false
|
99
|
-
configatron.cachetastic_default_options.store_options.urlencode = false
|
100
|
-
|
101
|
-
# set the servers to be used for memcache
|
102
|
-
configatron.cachetastic_default_options.servers = ["127.0.0.1:11211"] # ip:port used for memcache
|
103
|
-
|
104
|
-
# listed below are the options for file:
|
105
|
-
configatron.cachetastic_default_options.store_options.dir = "/cachetastic/caches"
|
106
|
-
|
107
|
-
# listed below are the options for drb:
|
108
|
-
configatron.cachetastic_default_options.servers = ["druby://127.0.0.1:61676"]
|
109
|
-
|
110
|
-
# configure logging for this cache
|
111
|
-
# n number of logs can be configured for a cache
|
112
|
-
log_1 = Logger.new(STDOUT)
|
113
|
-
log_1.level = Logger::DEBUG
|
114
|
-
log_2 = Logger.new("log/cachetastic.log")
|
115
|
-
log_2.level = Logger::ERROR
|
116
|
-
configatron.cachetastic_default_options.logger = [log_1, log_2]
|
117
|
-
</pre>
|
118
|
-
<h1>Cachetastic::Drb::Server</h1>
|
119
|
-
<p>
|
120
|
-
If you want to use Drb and the <a
|
121
|
-
href="../../classes/Cachetastic/Adapters/Drb.html">Cachetastic::Adapters::Drb</a>
|
122
|
-
adapter, you‘ll have to use the Cachetastic::Drb::Server that comes
|
123
|
-
with Cachetastic. Using this server is simple. It gets installed as a
|
124
|
-
binary when you install the Cachetastic gem.
|
125
|
-
</p>
|
126
|
-
<pre>
|
127
|
-
$ cachetastic_drb_server # that will start the drb server on the host 127.0.0.1 on the port 61676
|
128
|
-
</pre>
|
129
|
-
<p>
|
130
|
-
The server takes to command line parameters: -h <host> -p
|
131
|
-
<port> -v <verbose> -rv <really verbose>
|
132
|
-
</p>
|
133
|
-
<h1>Examples:</h1>
|
134
|
-
<pre>
|
135
|
-
class MyAwesomeCache < Cachetastic::Caches::Base
|
136
|
-
end
|
137
|
-
|
138
|
-
MyAwesomeCache.set(1, [1,2,3])
|
139
|
-
MyAwesomeCache.get(1) # => [1,2,3]
|
140
|
-
|
141
|
-
class MyAwesomeCache < Cachetastic::Caches::Base
|
142
|
-
class << self
|
143
|
-
def get(key, x, y)
|
144
|
-
super(key) do
|
145
|
-
n = x + y
|
146
|
-
set(key, n)
|
147
|
-
n
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
MyAwesomeCache.get(1, 2, 4) # => 8
|
154
|
-
MyAwesomeCache.get(1, 4, 4) # => 8
|
155
|
-
</pre>
|
156
|
-
|
157
|
-
</div>
|
158
71
|
|
159
72
|
<div id="requires-list">
|
160
73
|
<h3 class="section-bar">Required files</h3>
|
161
74
|
|
162
75
|
<div class="name-list">
|
163
|
-
rubygems
|
164
|
-
singleton
|
165
|
-
logger
|
166
|
-
yaml
|
167
|
-
zlib
|
168
|
-
pp
|
169
|
-
drb
|
170
76
|
configatron
|
77
|
+
logger
|
78
|
+
activesupport
|
79
|
+
fileutils
|
171
80
|
memcache
|
172
81
|
</div>
|
173
82
|
</div>
|
data/doc/fr_class_index.html
CHANGED
@@ -20,28 +20,16 @@
|
|
20
20
|
<div id="index">
|
21
21
|
<h1 class="section-bar">Classes</h1>
|
22
22
|
<div id="index-entries">
|
23
|
-
<a href="classes/
|
24
|
-
<a href="classes/CGI/Session/CachetasticStore.html">CGI::Session::CachetasticStore</a><br />
|
23
|
+
<a href="classes/Cachetastic/Adapters.html">Cachetastic::Adapters</a><br />
|
25
24
|
<a href="classes/Cachetastic/Adapters/Base.html">Cachetastic::Adapters::Base</a><br />
|
26
|
-
<a href="classes/Cachetastic/Adapters/Drb.html">Cachetastic::Adapters::Drb</a><br />
|
27
25
|
<a href="classes/Cachetastic/Adapters/File.html">Cachetastic::Adapters::File</a><br />
|
28
|
-
<a href="classes/Cachetastic/Adapters/FileBase.html">Cachetastic::Adapters::FileBase</a><br />
|
29
|
-
<a href="classes/Cachetastic/Adapters/HtmlFile.html">Cachetastic::Adapters::HtmlFile</a><br />
|
30
26
|
<a href="classes/Cachetastic/Adapters/LocalMemory.html">Cachetastic::Adapters::LocalMemory</a><br />
|
31
|
-
<a href="classes/Cachetastic/Adapters/
|
27
|
+
<a href="classes/Cachetastic/Adapters/Memcached.html">Cachetastic::Adapters::Memcached</a><br />
|
28
|
+
<a href="classes/Cachetastic/Cache.html">Cachetastic::Cache</a><br />
|
32
29
|
<a href="classes/Cachetastic/Cacheable.html">Cachetastic::Cacheable</a><br />
|
33
30
|
<a href="classes/Cachetastic/Cacheable/ClassAndInstanceMethods.html">Cachetastic::Cacheable::ClassAndInstanceMethods</a><br />
|
34
31
|
<a href="classes/Cachetastic/Cacheable/ClassOnlyMethods.html">Cachetastic::Cacheable::ClassOnlyMethods</a><br />
|
35
|
-
<a href="classes/Cachetastic/Caches/Base.html">Cachetastic::Caches::Base</a><br />
|
36
|
-
<a href="classes/Cachetastic/Caches/Base/RegisteredCaches.html">Cachetastic::Caches::Base::RegisteredCaches</a><br />
|
37
|
-
<a href="classes/Cachetastic/Caches/MackSessionCache.html">Cachetastic::Caches::MackSessionCache</a><br />
|
38
|
-
<a href="classes/Cachetastic/Caches/PageCache.html">Cachetastic::Caches::PageCache</a><br />
|
39
|
-
<a href="classes/Cachetastic/Caches/RailsSessionCache.html">Cachetastic::Caches::RailsSessionCache</a><br />
|
40
|
-
<a href="classes/Cachetastic/Connection.html">Cachetastic::Connection</a><br />
|
41
|
-
<a href="classes/Cachetastic/Errors/UnsupportedAdapter.html">Cachetastic::Errors::UnsupportedAdapter</a><br />
|
42
32
|
<a href="classes/Cachetastic/Logger.html">Cachetastic::Logger</a><br />
|
43
|
-
<a href="classes/Object.html">Object</a><br />
|
44
|
-
<a href="classes/String.html">String</a><br />
|
45
33
|
</div>
|
46
34
|
</div>
|
47
35
|
</body>
|
data/doc/fr_file_index.html
CHANGED
@@ -20,29 +20,18 @@
|
|
20
20
|
<div id="index">
|
21
21
|
<h1 class="section-bar">Files</h1>
|
22
22
|
<div id="index-entries">
|
23
|
+
<a href="files/LICENSE.html">LICENSE</a><br />
|
23
24
|
<a href="files/README.html">README</a><br />
|
24
25
|
<a href="files/lib/cachetastic_rb.html">lib/cachetastic.rb</a><br />
|
25
26
|
<a href="files/lib/cachetastic/adapters/base_rb.html">lib/cachetastic/adapters/base.rb</a><br />
|
26
|
-
<a href="files/lib/cachetastic/adapters/drb_rb.html">lib/cachetastic/adapters/drb.rb</a><br />
|
27
27
|
<a href="files/lib/cachetastic/adapters/file_rb.html">lib/cachetastic/adapters/file.rb</a><br />
|
28
|
-
<a href="files/lib/cachetastic/adapters/file_base_rb.html">lib/cachetastic/adapters/file_base.rb</a><br />
|
29
|
-
<a href="files/lib/cachetastic/adapters/html_file_rb.html">lib/cachetastic/adapters/html_file.rb</a><br />
|
30
28
|
<a href="files/lib/cachetastic/adapters/local_memory_rb.html">lib/cachetastic/adapters/local_memory.rb</a><br />
|
31
|
-
<a href="files/lib/cachetastic/adapters/
|
32
|
-
<a href="files/lib/cachetastic/
|
29
|
+
<a href="files/lib/cachetastic/adapters/memcached_rb.html">lib/cachetastic/adapters/memcached.rb</a><br />
|
30
|
+
<a href="files/lib/cachetastic/cache_rb.html">lib/cachetastic/cache.rb</a><br />
|
33
31
|
<a href="files/lib/cachetastic/cacheable_rb.html">lib/cachetastic/cacheable.rb</a><br />
|
34
|
-
<a href="files/lib/cachetastic/
|
35
|
-
<a href="files/lib/cachetastic/caches/mack_session_cache_rb.html">lib/cachetastic/caches/mack_session_cache.rb</a><br />
|
36
|
-
<a href="files/lib/cachetastic/caches/page_cache_rb.html">lib/cachetastic/caches/page_cache.rb</a><br />
|
37
|
-
<a href="files/lib/cachetastic/caches/rails_session_cache_rb.html">lib/cachetastic/caches/rails_session_cache.rb</a><br />
|
38
|
-
<a href="files/lib/cachetastic/connection_rb.html">lib/cachetastic/connection.rb</a><br />
|
39
|
-
<a href="files/lib/cachetastic/errors/unsupported_adapter_rb.html">lib/cachetastic/errors/unsupported_adapter.rb</a><br />
|
32
|
+
<a href="files/lib/cachetastic/extensions/string_rb.html">lib/cachetastic/extensions/string.rb</a><br />
|
40
33
|
<a href="files/lib/cachetastic/logger_rb.html">lib/cachetastic/logger.rb</a><br />
|
41
|
-
<a href="files/lib/cachetastic/
|
42
|
-
<a href="files/lib/cachetastic/rails_extensions/cgi_session_store_rb.html">lib/cachetastic/rails_extensions/cgi_session_store.rb</a><br />
|
43
|
-
<a href="files/lib/cachetastic/ruby_extensions/kernel_rb.html">lib/cachetastic/ruby_extensions/kernel.rb</a><br />
|
44
|
-
<a href="files/lib/cachetastic/ruby_extensions/object_rb.html">lib/cachetastic/ruby_extensions/object.rb</a><br />
|
45
|
-
<a href="files/lib/cachetastic/ruby_extensions/string_rb.html">lib/cachetastic/ruby_extensions/string.rb</a><br />
|
34
|
+
<a href="files/lib/cachetastic/store_object_rb.html">lib/cachetastic/store_object.rb</a><br />
|
46
35
|
</div>
|
47
36
|
</div>
|
48
37
|
</body>
|
data/doc/fr_method_index.html
CHANGED
@@ -20,84 +20,32 @@
|
|
20
20
|
<div id="index">
|
21
21
|
<h1 class="section-bar">Methods</h1>
|
22
22
|
<div id="index-entries">
|
23
|
-
<a href="classes/Cachetastic/
|
24
|
-
<a href="classes/Cachetastic/
|
25
|
-
<a href="classes/Cachetastic/
|
26
|
-
<a href="classes/Cachetastic/Cacheable
|
27
|
-
<a href="classes/Cachetastic/
|
28
|
-
<a href="classes/Cachetastic/
|
29
|
-
<a href="classes/Cachetastic/
|
30
|
-
<a href="classes/
|
31
|
-
<a href="classes/
|
32
|
-
<a href="classes/Cachetastic/
|
33
|
-
<a href="classes/
|
34
|
-
<a href="classes/Cachetastic/Adapters/Base.html#
|
35
|
-
<a href="classes/Cachetastic/
|
36
|
-
<a href="classes/
|
37
|
-
<a href="classes/Cachetastic/
|
38
|
-
<a href="classes/Cachetastic/
|
39
|
-
<a href="classes/Cachetastic/
|
40
|
-
<a href="classes/Cachetastic/
|
41
|
-
<a href="classes/Cachetastic/
|
42
|
-
<a href="classes/Cachetastic/
|
43
|
-
<a href="classes/Cachetastic/
|
44
|
-
<a href="classes/Cachetastic/
|
45
|
-
<a href="classes/Cachetastic/Adapters/
|
46
|
-
<a href="classes/Cachetastic/
|
47
|
-
<a href="classes/Cachetastic/Adapters/
|
48
|
-
<a href="classes/Cachetastic/
|
49
|
-
<a href="classes/Cachetastic/Adapters/Memcache.html#M000014">expire_all (Cachetastic::Adapters::Memcache)</a><br />
|
50
|
-
<a href="classes/Cachetastic/Adapters/File.html#M000047">get (Cachetastic::Adapters::File)</a><br />
|
51
|
-
<a href="classes/Cachetastic/Caches/Base.html#M000052">get (Cachetastic::Caches::Base)</a><br />
|
52
|
-
<a href="classes/Cachetastic/Adapters/Drb.html#M000043">get (Cachetastic::Adapters::Drb)</a><br />
|
53
|
-
<a href="classes/Cachetastic/Adapters/HtmlFile.html#M000007">get (Cachetastic::Adapters::HtmlFile)</a><br />
|
54
|
-
<a href="classes/Cachetastic/Connection.html#M000076">get (Cachetastic::Connection)</a><br />
|
55
|
-
<a href="classes/Cachetastic/Adapters/Memcache.html#M000013">get (Cachetastic::Adapters::Memcache)</a><br />
|
56
|
-
<a href="classes/Cachetastic/Adapters/LocalMemory.html#M000025">get (Cachetastic::Adapters::LocalMemory)</a><br />
|
57
|
-
<a href="classes/Cachetastic/Cacheable/ClassOnlyMethods.html#M000068">get_from_cache (Cachetastic::Cacheable::ClassOnlyMethods)</a><br />
|
58
|
-
<a href="classes/ActiveRecord/Base.html#M000078">get_from_cache (ActiveRecord::Base)</a><br />
|
59
|
-
<a href="classes/Cachetastic/Adapters/Memcache.html#M000021">get_version (Cachetastic::Adapters::Memcache)</a><br />
|
60
|
-
<a href="classes/Cachetastic/Adapters/Memcache.html#M000020">increment_version (Cachetastic::Adapters::Memcache)</a><br />
|
61
|
-
<a href="classes/Cachetastic/Adapters/Memcache.html#M000015">inspect (Cachetastic::Adapters::Memcache)</a><br />
|
62
|
-
<a href="classes/Object.html#M000002">ivar_cache (Object)</a><br />
|
63
|
-
<a href="classes/Cachetastic/Caches/Base.html#M000059">logger (Cachetastic::Caches::Base)</a><br />
|
64
|
-
<a href="classes/Cachetastic/Caches/Base.html#M000062">marshall (Cachetastic::Caches::Base)</a><br />
|
65
|
-
<a href="classes/Cachetastic/Adapters/Memcache.html#M000018">namespace (Cachetastic::Adapters::Memcache)</a><br />
|
66
|
-
<a href="classes/Object.html#M000003">needs_method (Object)</a><br />
|
67
|
-
<a href="classes/Cachetastic/Logger.html#M000074">new (Cachetastic::Logger)</a><br />
|
68
|
-
<a href="classes/Cachetastic/Caches/Base/RegisteredCaches.html#M000065">new (Cachetastic::Caches::Base::RegisteredCaches)</a><br />
|
69
|
-
<a href="classes/Cachetastic/Connection.html#M000075">new (Cachetastic::Connection)</a><br />
|
70
|
-
<a href="classes/Cachetastic/Adapters/Base.html#M000035">new (Cachetastic::Adapters::Base)</a><br />
|
71
|
-
<a href="classes/Cachetastic/Errors/UnsupportedAdapter.html#M000006">new (Cachetastic::Errors::UnsupportedAdapter)</a><br />
|
72
|
-
<a href="classes/Cachetastic/Adapters/Memcache.html#M000019">ns_versions (Cachetastic::Adapters::Memcache)</a><br />
|
73
|
-
<a href="classes/Cachetastic/Adapters/LocalMemory.html#M000026">set (Cachetastic::Adapters::LocalMemory)</a><br />
|
74
|
-
<a href="classes/Cachetastic/Adapters/Memcache.html#M000011">set (Cachetastic::Adapters::Memcache)</a><br />
|
75
|
-
<a href="classes/Cachetastic/Caches/Base.html#M000053">set (Cachetastic::Caches::Base)</a><br />
|
76
|
-
<a href="classes/Cachetastic/Adapters/File.html#M000048">set (Cachetastic::Adapters::File)</a><br />
|
77
|
-
<a href="classes/Cachetastic/Adapters/HtmlFile.html#M000008">set (Cachetastic::Adapters::HtmlFile)</a><br />
|
78
|
-
<a href="classes/Cachetastic/Adapters/Drb.html#M000044">set (Cachetastic::Adapters::Drb)</a><br />
|
79
|
-
<a href="classes/Cachetastic/Cacheable/ClassOnlyMethods.html#M000070">set_into_cache (Cachetastic::Cacheable::ClassOnlyMethods)</a><br />
|
80
|
-
<a href="classes/Cachetastic/Adapters/LocalMemory.html#M000023">setup (Cachetastic::Adapters::LocalMemory)</a><br />
|
81
|
-
<a href="classes/Cachetastic/Adapters/Drb.html#M000041">setup (Cachetastic::Adapters::Drb)</a><br />
|
82
|
-
<a href="classes/Cachetastic/Adapters/Memcache.html#M000010">setup (Cachetastic::Adapters::Memcache)</a><br />
|
83
|
-
<a href="classes/Cachetastic/Adapters/FileBase.html#M000029">setup (Cachetastic::Adapters::FileBase)</a><br />
|
84
|
-
<a href="classes/Cachetastic/Adapters/Drb.html#M000046">stats (Cachetastic::Adapters::Drb)</a><br />
|
85
|
-
<a href="classes/Cachetastic/Adapters/Base.html#M000037">stats (Cachetastic::Adapters::Base)</a><br />
|
86
|
-
<a href="classes/Cachetastic/Adapters/FileBase.html#M000031">stats (Cachetastic::Adapters::FileBase)</a><br />
|
87
|
-
<a href="classes/Cachetastic/Adapters/Memcache.html#M000017">stats (Cachetastic::Adapters::Memcache)</a><br />
|
88
|
-
<a href="classes/Cachetastic/Adapters/LocalMemory.html#M000028">stats (Cachetastic::Adapters::LocalMemory)</a><br />
|
89
|
-
<a href="classes/Cachetastic/Caches/Base.html#M000056">stats (Cachetastic::Caches::Base)</a><br />
|
90
|
-
<a href="classes/Cachetastic/Adapters/HtmlFile.html#M000009">store_file_name (Cachetastic::Adapters::HtmlFile)</a><br />
|
91
|
-
<a href="classes/Cachetastic/Adapters/File.html#M000049">store_file_name (Cachetastic::Adapters::File)</a><br />
|
92
|
-
<a href="classes/Cachetastic/Adapters/FileBase.html#M000034">store_file_name (Cachetastic::Adapters::FileBase)</a><br />
|
93
|
-
<a href="classes/Cachetastic/Cacheable.html#M000067">uncache_self (Cachetastic::Cacheable)</a><br />
|
94
|
-
<a href="classes/Cachetastic/Caches/Base.html#M000063">unmarshall (Cachetastic::Caches::Base)</a><br />
|
95
|
-
<a href="classes/Cachetastic/Caches/RailsSessionCache.html#M000050">unsupported_adapters (Cachetastic::Caches::RailsSessionCache)</a><br />
|
96
|
-
<a href="classes/Cachetastic/Caches/Base.html#M000060">unsupported_adapters (Cachetastic::Caches::Base)</a><br />
|
97
|
-
<a href="classes/Cachetastic/Adapters/Drb.html#M000040">valid? (Cachetastic::Adapters::Drb)</a><br />
|
98
|
-
<a href="classes/Cachetastic/Adapters/LocalMemory.html#M000022">valid? (Cachetastic::Adapters::LocalMemory)</a><br />
|
99
|
-
<a href="classes/Cachetastic/Adapters/Memcache.html#M000016">valid? (Cachetastic::Adapters::Memcache)</a><br />
|
100
|
-
<a href="classes/Cachetastic/Adapters/FileBase.html#M000030">valid? (Cachetastic::Adapters::FileBase)</a><br />
|
23
|
+
<a href="classes/Cachetastic/Cache.html#M000022">adapter (Cachetastic::Cache)</a><br />
|
24
|
+
<a href="classes/Cachetastic/Adapters.html#M000001">build (Cachetastic::Adapters)</a><br />
|
25
|
+
<a href="classes/Cachetastic/Cacheable/ClassAndInstanceMethods.html#M000015">cache_class (Cachetastic::Cacheable::ClassAndInstanceMethods)</a><br />
|
26
|
+
<a href="classes/Cachetastic/Cacheable.html#M000010">cache_self (Cachetastic::Cacheable)</a><br />
|
27
|
+
<a href="classes/Cachetastic/Cacheable/ClassAndInstanceMethods.html#M000016">cacher (Cachetastic::Cacheable::ClassAndInstanceMethods)</a><br />
|
28
|
+
<a href="classes/Cachetastic/Cache.html#M000025">calculate_expiry_time (Cachetastic::Cache)</a><br />
|
29
|
+
<a href="classes/Cachetastic/Cache.html#M000023">clear_adapter! (Cachetastic::Cache)</a><br />
|
30
|
+
<a href="classes/Cachetastic/Cache.html#M000020">delete (Cachetastic::Cache)</a><br />
|
31
|
+
<a href="classes/Cachetastic/Adapters/Base.html#M000006">delete (Cachetastic::Adapters::Base)</a><br />
|
32
|
+
<a href="classes/Cachetastic/Cacheable/ClassOnlyMethods.html#M000013">delete_from_cache (Cachetastic::Cacheable::ClassOnlyMethods)</a><br />
|
33
|
+
<a href="classes/Cachetastic/Cache.html#M000021">expire_all (Cachetastic::Cache)</a><br />
|
34
|
+
<a href="classes/Cachetastic/Adapters/Base.html#M000007">expire_all (Cachetastic::Adapters::Base)</a><br />
|
35
|
+
<a href="classes/Cachetastic/Cacheable/ClassAndInstanceMethods.html#M000017">expire_all (Cachetastic::Cacheable::ClassAndInstanceMethods)</a><br />
|
36
|
+
<a href="classes/Cachetastic/Adapters/Base.html#M000004">get (Cachetastic::Adapters::Base)</a><br />
|
37
|
+
<a href="classes/Cachetastic/Cache.html#M000018">get (Cachetastic::Cache)</a><br />
|
38
|
+
<a href="classes/Cachetastic/Cacheable/ClassOnlyMethods.html#M000012">get_from_cache (Cachetastic::Cacheable::ClassOnlyMethods)</a><br />
|
39
|
+
<a href="classes/Cachetastic/Cache.html#M000024">logger (Cachetastic::Cache)</a><br />
|
40
|
+
<a href="classes/Cachetastic/Adapters/Base.html#M000003">new (Cachetastic::Adapters::Base)</a><br />
|
41
|
+
<a href="classes/Cachetastic/Logger.html#M000026">new (Cachetastic::Logger)</a><br />
|
42
|
+
<a href="classes/Cachetastic/Cache.html#M000019">set (Cachetastic::Cache)</a><br />
|
43
|
+
<a href="classes/Cachetastic/Adapters/Base.html#M000005">set (Cachetastic::Adapters::Base)</a><br />
|
44
|
+
<a href="classes/Cachetastic/Cacheable/ClassOnlyMethods.html#M000014">set_into_cache (Cachetastic::Cacheable::ClassOnlyMethods)</a><br />
|
45
|
+
<a href="classes/Cachetastic/Adapters/Base.html#M000008">transform_key (Cachetastic::Adapters::Base)</a><br />
|
46
|
+
<a href="classes/Cachetastic/Cacheable.html#M000011">uncache_self (Cachetastic::Cacheable)</a><br />
|
47
|
+
<a href="classes/Cachetastic/Adapters/Memcached.html#M000002">valid? (Cachetastic::Adapters::Memcached)</a><br />
|
48
|
+
<a href="classes/Cachetastic/Adapters/Base.html#M000009">valid? (Cachetastic::Adapters::Base)</a><br />
|
101
49
|
</div>
|
102
50
|
</div>
|
103
51
|
</body>
|
data/lib/cachetastic.rb
CHANGED
@@ -1,74 +1,20 @@
|
|
1
|
-
# :include: README
|
2
|
-
require 'rubygems'
|
3
|
-
require 'singleton'
|
4
|
-
require 'logger'
|
5
|
-
require 'yaml'
|
6
|
-
require 'zlib'
|
7
|
-
require 'pp'
|
8
|
-
require 'drb'
|
9
1
|
require 'configatron'
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
# if you don't have memcache installed, don't
|
15
|
-
# blow up, print a message, and you can't use
|
16
|
-
# the memcache adapter.
|
17
|
-
puts "CACHETASTIC: Warning: You don't have the memcache gem installed which means you can't use the Cachetastic::Adapters::Memcache adapter."
|
18
|
-
end
|
19
|
-
|
20
|
-
class Object
|
21
|
-
# Uses <code>define_method</code> to create an empty for the method parameter defined.
|
22
|
-
# That method will then raise MethodNotImplemented. This is useful for creating interfaces
|
23
|
-
# and you want to stub out methods that others need to implement.
|
24
|
-
def self.needs_method(meth)
|
25
|
-
define_method(meth) do
|
26
|
-
raise NoMethodError.new("The interface you are using requires you define the following method '#{meth}'")
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
2
|
+
require 'logger'
|
3
|
+
require 'activesupport'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'memcache'
|
30
6
|
|
31
|
-
|
32
|
-
|
33
|
-
end
|
34
|
-
module Adapters #:nodoc:#
|
35
|
-
end
|
36
|
-
module Errors #:nodoc:#
|
37
|
-
end
|
38
|
-
module Cacheable
|
39
|
-
end
|
7
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'cachetastic', '**/*.rb')).each do |f|
|
8
|
+
require File.expand_path(f)
|
40
9
|
end
|
41
|
-
module ActiveRecord #:nodoc:#
|
42
|
-
end
|
43
|
-
|
44
|
-
home = File.join(File.dirname(__FILE__), 'cachetastic')
|
45
|
-
|
46
|
-
require File.join(home, 'connection')
|
47
|
-
require File.join(home, 'logger')
|
48
|
-
require File.join(home, 'caches/base')
|
49
|
-
require File.join(home, 'caches/page_cache')
|
50
|
-
require File.join(home, 'caches/rails_session_cache')
|
51
|
-
require File.join(home, 'caches/mack_session_cache')
|
52
|
-
require File.join(home, 'errors/unsupported_adapter')
|
53
|
-
require File.join(home, 'adapters/base')
|
54
|
-
require File.join(home, 'adapters/store_object')
|
55
|
-
require File.join(home, 'adapters/memcache')
|
56
|
-
require File.join(home, 'adapters/local_memory')
|
57
|
-
require File.join(home, 'adapters/file_base')
|
58
|
-
require File.join(home, 'adapters/file')
|
59
|
-
require File.join(home, 'adapters/html_file')
|
60
|
-
require File.join(home, 'adapters/drb')
|
61
|
-
require File.join(home, 'cacheable')
|
62
|
-
require File.join(home, 'rails_extensions/active_record_base')
|
63
|
-
require File.join(home, 'rails_extensions/cgi_session_store')
|
64
|
-
require File.join(home, 'ruby_extensions/object')
|
65
|
-
require File.join(home, 'ruby_extensions/kernel')
|
66
|
-
require File.join(home, 'ruby_extensions/string')
|
67
|
-
|
68
|
-
configatron.cachetastic_default_options.set_default(:debug, false)
|
69
|
-
configatron.cachetastic_default_options.set_default(:adapter, :local_memory)
|
70
|
-
configatron.cachetastic_default_options.set_default(:logger, ::Logger.new(STDOUT))
|
71
10
|
|
72
|
-
|
73
|
-
|
74
|
-
|
11
|
+
configatron.cachetastic.defaults.set_default(:marshal_method, :none)
|
12
|
+
configatron.cachetastic.defaults.set_default(:expiry_swing, 0)
|
13
|
+
configatron.cachetastic.defaults.set_default(:default_expiry, 86400)
|
14
|
+
configatron.cachetastic.defaults.set_default(:debug, true)
|
15
|
+
configatron.cachetastic.defaults.set_default(:adapter, Cachetastic::Adapters::LocalMemory)
|
16
|
+
log_path = File.join(FileUtils.pwd, 'log', 'cachetastic.log')
|
17
|
+
FileUtils.mkdir_p(File.dirname(log_path))
|
18
|
+
logger = ::Logger.new(log_path)
|
19
|
+
logger.level = ::Logger::DEBUG
|
20
|
+
configatron.cachetastic.defaults.set_default(:logger, logger)
|
@@ -1,76 +1,178 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
class Cachetastic::Adapters::
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
end
|
1
|
+
module Cachetastic # :nodoc:
|
2
|
+
module Adapters
|
3
|
+
|
4
|
+
class << self
|
5
|
+
|
6
|
+
# This method will return the appropriate
|
7
|
+
# <tt>Cachetastic::Adapters::Base</tt> class that is defined
|
8
|
+
# for the Class passed in. If an adapter has not been
|
9
|
+
# defined for the Class than the default adapter is returned.
|
10
|
+
#
|
11
|
+
# Examples:
|
12
|
+
# configatron.cachetastic.defaults.adapter = Cachetastic::Adapters::LocalMemory
|
13
|
+
# configatron.cachetastic.user.adapter = Cachetastic::Adapters::Memcached
|
14
|
+
# Cachetastic::Adapters.build(User).class # => Cachetastic::Adapters::Memcached
|
15
|
+
# Cachetastic::Adapters.build(Comment).class # => Cachetastic::Adapters::LocalMemory
|
16
|
+
def build(klass)
|
17
|
+
adp = klass.to_configatron(:cachetastic).adapter
|
18
|
+
if adp.nil?
|
19
|
+
adp = configatron.cachetastic.defaults.adapter
|
20
|
+
end
|
21
|
+
adp.new(klass)
|
22
|
+
end
|
23
|
+
|
24
|
+
end # class << self
|
25
|
+
|
26
|
+
# This class should be extended to create new adapters for various
|
27
|
+
# backends. It is important that all subclasses call the <tt>initialize</tt>
|
28
|
+
# method in this base, otherwise things just will not work right.
|
29
|
+
#
|
30
|
+
# This base class provides common functionality and an API for all
|
31
|
+
# adapters to be used with Cachetastic.
|
32
|
+
#
|
33
|
+
# The default settings for all adapters are:
|
34
|
+
#
|
35
|
+
# configatron.cachetastic.defaults.marshal_method = :none
|
36
|
+
# configatron.cachetastic.defaults.expiry_swing = 0
|
37
|
+
# configatron.cachetastic.defaults.default_expiry = 86400
|
38
|
+
# configatron.cachetastic.defaults.debug = true
|
39
|
+
# configatron.cachetastic.defaults.adapter = Cachetastic::Adapters::LocalMemory
|
40
|
+
# logger = ::Logger.new(File.join(FileUtils.pwd, 'log', 'cachetastic.log'))
|
41
|
+
# logger.level = ::Logger::DEBUG
|
42
|
+
# configatron.cachetastic.defaults.logger = logger
|
43
|
+
#
|
44
|
+
# See the README for more information on what each of those settings mean,
|
45
|
+
# and what are values may be used for each one.
|
46
|
+
class Base
|
47
|
+
|
48
|
+
# The Class that this adapter is associated with. Note that it is a
|
49
|
+
# <i>class</i> reference and not an instance reference.
|
50
|
+
attr_accessor :klass
|
51
|
+
|
52
|
+
# Creates a new adapter. It takes a class reference to tie the
|
53
|
+
# instance of the adapter to a particular class. Note that it is a
|
54
|
+
# <i>class</i> reference and not an instance reference.
|
55
|
+
#
|
56
|
+
# Examples:
|
57
|
+
# Cachetastic::Adapters::Base.new(User)
|
58
|
+
#
|
59
|
+
# Adapters are configured using the Configatron gem.
|
60
|
+
#
|
61
|
+
# Examples:
|
62
|
+
# configatron.cachetastic.user.adapter = Cachetastic::Adapters::File
|
63
|
+
# configatron.cachetastic.user.expiry_time = 5.hours
|
64
|
+
# configatron.cachetastic.defaults.expiry_time = 24.hours
|
65
|
+
#
|
66
|
+
# Refered to each adapter for its specific configuration settings.
|
67
|
+
def initialize(klass)
|
68
|
+
self.klass = klass
|
69
|
+
configatron.cachetastic.defaults.configatron_keys.each do |key|
|
70
|
+
define_accessor(key)
|
71
|
+
self.send("#{key}=", configatron.cachetastic.defaults.send(key))
|
72
|
+
end
|
73
|
+
klass.to_configatron(:cachetastic).configatron_keys.each do |key|
|
74
|
+
define_accessor(key)
|
75
|
+
self.send("#{key}=", klass.to_configatron(:cachetastic).send(key))
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# <b>This method MUST be implemented by a subclass!</b>
|
80
|
+
#
|
81
|
+
# The implementation of this method should take a key and return
|
82
|
+
# an associated object, if available, from the underlying persistence
|
83
|
+
# layer.
|
84
|
+
def get(key)
|
85
|
+
raise NoMethodError.new('get')
|
86
|
+
end # get
|
87
|
+
|
88
|
+
# <b>This method MUST be implemented by a subclass!</b>
|
89
|
+
#
|
90
|
+
# The implementation of this method should take a key, a value, and
|
91
|
+
# an expiry time and save it to the persistence store, where it should
|
92
|
+
# live until it is either deleted by the user of the expiry time has passed.
|
93
|
+
def set(key, value, expiry_time = configatron.cachetastic.defaults.default_expiry)
|
94
|
+
raise NoMethodError.new('set')
|
95
|
+
end # set
|
96
|
+
|
97
|
+
# <b>This method MUST be implemented by a subclass!</b>
|
98
|
+
#
|
99
|
+
# The implementation of this method should take a key and remove
|
100
|
+
# an object, if it exists, from an underlying persistence store.
|
101
|
+
def delete(key)
|
102
|
+
raise NoMethodError.new('delete')
|
103
|
+
end # delete
|
104
|
+
|
105
|
+
# <b>This method MUST be implemented by a subclass!</b>
|
106
|
+
#
|
107
|
+
# The implementation of this method is expected to delete all
|
108
|
+
# objects belonging to the associated cache from the underlying
|
109
|
+
# persistence store. It is <b>NOT</b> meant to delete <b>ALL</b>
|
110
|
+
# objects across <b>ALL</b> caches for the underlying persistence
|
111
|
+
# store. That would be very very bad!!
|
112
|
+
def expire_all
|
113
|
+
raise NoMethodError.new('expire_all')
|
114
|
+
end # expire_all
|
115
|
+
|
116
|
+
# Allows an adapter to transform the key
|
117
|
+
# to a safe representation for it's backend.
|
118
|
+
# For example, the key: '$*...123()%~q' is not a
|
119
|
+
# key for the file system, so the
|
120
|
+
# Cachetastic::Adapters::File class should override
|
121
|
+
# this to make it safe for the file system.
|
122
|
+
def transform_key(key)
|
123
|
+
key
|
124
|
+
end
|
125
|
+
|
126
|
+
# <b>This method MUST be implemented by a subclass!</b>
|
127
|
+
#
|
128
|
+
# The implementation of this method should return <tt>true</tt>
|
129
|
+
# if the adapter is in a valid state, and <tt>false</tt> if it is
|
130
|
+
# not.
|
131
|
+
def valid?
|
132
|
+
true
|
133
|
+
end
|
134
|
+
|
135
|
+
def debug? # :nodoc:
|
136
|
+
return self.debug if self.respond_to?(:debug)
|
137
|
+
return false
|
138
|
+
end
|
139
|
+
|
140
|
+
def marshal(value) # :nodoc:
|
141
|
+
return nil if value.nil?
|
142
|
+
case self.marshal_method.to_sym
|
143
|
+
when :yaml
|
144
|
+
return YAML.dump(value)
|
145
|
+
when :ruby
|
146
|
+
return Marshal.dump(value)
|
147
|
+
else
|
148
|
+
return value
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def unmarshal(value) # :nodoc:
|
153
|
+
return nil if value.nil?
|
154
|
+
case self.marshal_method.to_sym
|
155
|
+
when :yaml
|
156
|
+
return YAML.load(value)
|
157
|
+
when :ruby
|
158
|
+
return Marshal.load(value)
|
159
|
+
else
|
160
|
+
return value
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
private
|
165
|
+
def define_accessor(key)
|
166
|
+
instance_eval(%{
|
167
|
+
def #{key}
|
168
|
+
@#{key}
|
169
|
+
end
|
170
|
+
def #{key}=(x)
|
171
|
+
@#{key} = x
|
172
|
+
end
|
173
|
+
})
|
174
|
+
end
|
175
|
+
|
176
|
+
end # Base
|
177
|
+
end # Adapters
|
178
|
+
end # Cachetastic
|