Sha256: 66465d6161a2dcbaffbff1f678c063c469f963796769034084fa03c44145e2aa
Contents?: true
Size: 995 Bytes
Versions: 4
Compression:
Stored size: 995 Bytes
Contents
## # This module provides a simple key/value cache for storing computation results module BasicCache # Check if we're using a version if Ruby that supports caller_locations NEW_CALL = Kernel.respond_to? 'caller_locations' class << self ## # Insert a helper .new() method for creating a new Cache object def new(*args) self::Cache.new(*args) end ## # 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() def caller_name NEW_CALL ? caller_locations(2, 1).first.label : caller[1][/`([^']*)'/, 1] end end end require 'basiccache/stores/store' require 'basiccache/stores/nullstore' require 'basiccache/caches/cache' require 'basiccache/caches/timecache' require 'basiccache/methodcacher'
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
basiccache-1.0.0 | lib/basiccache.rb |
basiccache-0.2.2 | lib/basiccache.rb |
basiccache-0.2.1 | lib/basiccache.rb |
basiccache-0.2.0 | lib/basiccache.rb |