Module: Wrest::Caching
- Defined in:
- lib/wrest/caching.rb,
lib/wrest/caching/redis.rb,
lib/wrest/caching/memcached.rb
Defined Under Namespace
Class Method Summary collapse
-
.default_store ⇒ Object
Returns the default store for caching, if any is set.
-
.default_store=(store) ⇒ Object
Assign the default cache store to be used.
-
.default_to_hash! ⇒ Object
Configures Wrest to cache all requests.
-
.default_to_memcached! ⇒ Object
Default Wrest to using memcached for caching requests.
-
.default_to_redis!(redis_options = {}) ⇒ Object
Default Wrest to using redis for caching requests.
-
.enable_memcached ⇒ Object
Loads the Memcached caching back-end and the Dalli gem.
-
.enable_redis ⇒ Object
Loads the Redis caching back-end and the Redis gem.
Class Method Details
.default_store ⇒ Object
Returns the default store for caching, if any is set.
53 54 55 |
# File 'lib/wrest/caching.rb', line 53 def self.default_store @default_store end |
.default_store=(store) ⇒ Object
Assign the default cache store to be used. Default is none.
48 49 50 |
# File 'lib/wrest/caching.rb', line 48 def self.default_store=(store) @default_store = store end |
.default_to_hash! ⇒ Object
Configures Wrest to cache all requests. This will use a Ruby Hash. WARNING: This should NEVER be used in a real environment. The Hash will keep growing since Wrest does not limit the size of a cache store.
Please switch to the memcached or redis back-end for production use.
29 30 31 |
# File 'lib/wrest/caching.rb', line 29 def self.default_to_hash! self.default_store = ({}) end |
.default_to_memcached! ⇒ Object
Default Wrest to using memcached for caching requests.
34 35 36 37 |
# File 'lib/wrest/caching.rb', line 34 def self.default_to_memcached! enable_memcached self.default_store = Wrest::Caching::Memcached.new end |
.default_to_redis!(redis_options = {}) ⇒ Object
Default Wrest to using redis for caching requests.
Options to configuring the redis gem can be passed as arguments.
42 43 44 45 |
# File 'lib/wrest/caching.rb', line 42 def self.default_to_redis!( = {}) enable_redis self.default_store = Wrest::Caching::Redis.new() end |
.enable_memcached ⇒ Object
Loads the Memcached caching back-end and the Dalli gem
15 16 17 |
# File 'lib/wrest/caching.rb', line 15 def self.enable_memcached require 'wrest/caching/memcached' end |
.enable_redis ⇒ Object
Loads the Redis caching back-end and the Redis gem
20 21 22 |
# File 'lib/wrest/caching.rb', line 20 def self.enable_redis require 'wrest/caching/redis' end |