Class: Restfulie::Client::Cache::Basic

Inherits:
Object
  • Object
show all
Defined in:
lib/restfulie/client/cache/basic.rb

Instance Method Summary collapse

Instance Method Details

#clearObject

removes all elements from the cache



32
33
34
# File 'lib/restfulie/client/cache/basic.rb', line 32

def clear
  cache.clear
end

#get(key, request) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/restfulie/client/cache/basic.rb', line 17

def get(key, request)

  response = cache_get(key, request)
  return nil if response.nil?

  if response.has_expired_cache?
    remove(key)
  else
    Restfulie::Common::Logger.logger.debug "RETURNING cache #{key}"
    cache_hit response
  end

end

#put(key, req, response) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/restfulie/client/cache/basic.rb', line 9

def put(key, req, response)
  if Restfulie::Client::Cache::Restrictions.may_cache?(response)
    Restfulie::Common::Logger.logger.debug "caching #{key} #{response}"
    cache_add(key, req, response)
  end
  response
end