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

+ (Object) default_store

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

+ (Object) default_store=(store)

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

+ (Object) default_to_hash!

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

+ (Object) default_to_memcached!

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

+ (Object) enable_memcached

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