cachetastic 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/adapters/cachetastic_adapters_file.rb +2 -0
- data/lib/caches/cachetastic_caches_base.rb +18 -1
- data/lib/caches/cachetastic_caches_rails_session_cache.rb +9 -0
- data/lib/cachetastic.rb +3 -0
- data/lib/errors/cachetastic_errors_unsupported_adapter.rb +7 -0
- data/lib/tasks/rubyforge_config.yml +1 -1
- metadata +2 -1
@@ -139,7 +139,12 @@ class Cachetastic::Caches::Base
|
|
139
139
|
|
140
140
|
# Returns the underlying Cachetastic::Adapters::Base for this cache.
|
141
141
|
def adapter
|
142
|
-
cache_conn_instance.get(cache_name)
|
142
|
+
a = cache_conn_instance.get(cache_name)
|
143
|
+
if adapter_supported?(a.class)
|
144
|
+
return a
|
145
|
+
else
|
146
|
+
raise Cachetastic::Errors::UnsupportedAdapter.new(cache_name, a.class)
|
147
|
+
end
|
143
148
|
end
|
144
149
|
|
145
150
|
# Returns the Cachetastic::Logger for the underlying Cachetastic::Adapters::Base.
|
@@ -147,6 +152,18 @@ class Cachetastic::Caches::Base
|
|
147
152
|
adapter.logger
|
148
153
|
end
|
149
154
|
|
155
|
+
# Returns an array of unsupported adapters for this cache. Defaults to an empty
|
156
|
+
# array which will let any adapter be used by the cache. Override in your specific
|
157
|
+
# cache to prevent certain adapters.
|
158
|
+
def unsupported_adapters
|
159
|
+
[]
|
160
|
+
end
|
161
|
+
|
162
|
+
# Returns true/false on whether the adapter you want to use is supported for the cache.
|
163
|
+
def adapter_supported?(a = cache_conn_instance.get(cache_name).class)
|
164
|
+
return !unsupported_adapters.include?(a)
|
165
|
+
end
|
166
|
+
|
150
167
|
private
|
151
168
|
# If the expiry time is set to 60 minutes and the expiry_swing time is set to
|
152
169
|
# 15 minutes, this method will return a number between 45 minutes and 75 minutes.
|
data/lib/cachetastic.rb
CHANGED
@@ -14,6 +14,8 @@ module Cachetastic #:nodoc:#
|
|
14
14
|
end
|
15
15
|
module Adapters #:nodoc:#
|
16
16
|
end
|
17
|
+
module Errors #:nodoc:#
|
18
|
+
end
|
17
19
|
module Helpers #:nodoc:#
|
18
20
|
module ActiveRecord #:nodoc:#
|
19
21
|
end
|
@@ -27,6 +29,7 @@ require 'cachetastic_logger'
|
|
27
29
|
require 'caches/cachetastic_caches_base'
|
28
30
|
require 'caches/cachetastic_caches_page_cache'
|
29
31
|
require 'caches/cachetastic_caches_rails_session_cache'
|
32
|
+
require 'errors/cachetastic_errors_unsupported_adapter'
|
30
33
|
require 'adapters/cachetastic_adapters_base'
|
31
34
|
require 'adapters/cachetastic_adapters_store_object'
|
32
35
|
require 'adapters/cachetastic_adapters_memcache'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cachetastic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- markbates
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- lib/cachetastic.rb
|
124
124
|
- lib/cachetastic_connection.rb
|
125
125
|
- lib/cachetastic_logger.rb
|
126
|
+
- lib/errors/cachetastic_errors_unsupported_adapter.rb
|
126
127
|
- lib/helpers/cachetastic_helpers_active_record.rb
|
127
128
|
- lib/rails_extensions/cachetastic_active_record_base.rb
|
128
129
|
- lib/rails_extensions/cgi_session_cachetastic_store.rb
|