module BasicCache
This module provides a simple key/value cache for storing computation results
Define the basic cache and default store objects
Extends BasicCache
to add a time-based cache
Constants
- DEFAULT_STORE
Set default
Store
type- NEW_CALL
Check if we’re using a version if Ruby that supports caller_locations
- TimeCacheItem
Timecache item struct, timestamp and value
Public Class Methods
caller_name()
click to toggle source
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()
# File lib/basiccache.rb, line 22 def caller_name NEW_CALL ? caller_locations(2, 1).first.label : caller[1][/`([^']*)'/, 1] end
new(*args)
click to toggle source
Insert a helper .new() method for creating a new Cache
object
# File lib/basiccache.rb, line 11 def new(*args) self::Cache.new(*args) end