Module: BasicCache

Defined in:
lib/basiccache.rb,
lib/caches/cache.rb,
lib/stores/store.rb,
lib/caches/timecache.rb

Overview

Extends BasicCache to add a time-based cache

Defined Under Namespace

Classes: Cache, Store, TimeCache, TimeCacheItem

Constant Summary collapse

NEW_CALL =

Check if we’re using a version if Ruby that supports caller_locations

Kernel.respond_to? 'caller_locations'
DEFAULT_STORE =

Set default Store type

BasicCache::Store

Class Method Summary collapse

Class Method Details

.caller_nameObject

Provide a helper method to get the calling function name If available, caller_locations is available and is much faster. If not, fall back to caller These methods return the name of the calling function 2 levels up This allows them to return the name of whatever called Cache.cache()



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

def caller_name
  NEW_CALL ? caller_locations(2, 1).first.label : caller[1][/`([^']*)'/, 1]
end

.new(*args) ⇒ Object

Insert a helper .new() method for creating a new Cache object



11
12
13
# File 'lib/basiccache.rb', line 11

def new(*args)
  self::Cache.new(*args)
end