class GH::Cache

Public: This class caches responses.

Attributes

cache[RW]

Public: Get/set cache to use. Compatible with Rails/ActiveSupport cache.

Public Instance Methods

reset() click to toggle source

Public: …

Calls superclass method
# File lib/gh/cache.rb, line 41
def reset
  super
  clear_partial or clear_all
end
setup(*) click to toggle source

Internal: Initializes a new Cache instance.

Calls superclass method
# File lib/gh/cache.rb, line 33
def setup(*)
  #self.cache ||= Rails.cache if defined? Rails.cache and defined? RAILS_CACHE
  #self.cache ||= ActiveSupport::Cache.lookup_store if defined? ActiveSupport::Cache.lookup_store
  self.cache ||= SimpleCache.new
  super
end

Private Instance Methods

clear_all() click to toggle source
# File lib/gh/cache.rb, line 61
def clear_all
  cache.clear
end
clear_partial() click to toggle source
# File lib/gh/cache.rb, line 52
def clear_partial
  return false unless cache.respond_to? :delete_matched
  pattern = "^" << Regexp.escape(prefixed(""))
  cache.delete_matched Regexp.new(pattern)
  true
rescue NotImplementedError
  false
end
fetch_resource(key) click to toggle source
Calls superclass method
# File lib/gh/cache.rb, line 48
def fetch_resource(key)
  cache.fetch(prefixed(key)) { super }
end