Module: Wrest::Caching

Defined in:
lib/wrest/caching.rb,
lib/wrest/caching/memcached.rb

Defined Under Namespace

Classes: Memcached

Class Method Summary collapse

Class Method Details

.default_storeObject

Returns the default store for caching, if any is set.



38
39
40
# File 'lib/wrest/caching.rb', line 38

def self.default_store
  @default_store
end

.default_store=(store) ⇒ Object

Assign the default cache store to be used. Default is none.



33
34
35
# File 'lib/wrest/caching.rb', line 33

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 on growing since Wrest does not limit the size of a cache store.

Use the Memcached caching back-end for production since the Memcached process uses an LRU based cache removal policy that keeps the number of entries stored within bounds.



22
23
24
# File 'lib/wrest/caching.rb', line 22

def self.default_to_hash!
  self.default_store = Hash.new
end

.default_to_memcached!Object

Default Wrest to using memcached for caching requests.



27
28
29
30
# File 'lib/wrest/caching.rb', line 27

def self.default_to_memcached!
  self.enable_memcached
  self.default_store = Wrest::Caching::Memcached.new 
end

.enable_memcachedObject

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::Root}/wrest/caching/memcached"
end