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.
51 52 53 |
# File 'lib/wrest/caching.rb', line 51 def self.default_store @default_store end |
.default_store=(store) ⇒ Object
Assign the default cache store to be used. Default is none.
46 47 48 |
# File 'lib/wrest/caching.rb', line 46 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.
27 28 29 |
# File 'lib/wrest/caching.rb', line 27 def self.default_to_hash! self.default_store = Hash.new end |
.default_to_memcached! ⇒ Object
Default Wrest to using memcached for caching requests.
32 33 34 35 |
# File 'lib/wrest/caching.rb', line 32 def self.default_to_memcached! self.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.
40 41 42 43 |
# File 'lib/wrest/caching.rb', line 40 def self.default_to_redis!( = {}) self.enable_redis self.default_store = Wrest::Caching::Redis.new() end |
.enable_memcached ⇒ Object
Loads the Memcached caching back-end and the Dalli gem
13 14 15 |
# File 'lib/wrest/caching.rb', line 13 def self.enable_memcached require "wrest/caching/memcached" end |
.enable_redis ⇒ Object
Loads the Redis caching back-end and the Redis gem
18 19 20 |
# File 'lib/wrest/caching.rb', line 18 def self.enable_redis require "wrest/caching/redis" end |