Module | PhusionPassenger::ClassicRailsExtensions::AnalyticsLogging::CacheStoreExtension
In: | lib/phusion_passenger/classic_rails_extensions/analytics_logging/as_cache_extension.rb

### Methods

fetch_2_1 fetch_2_2 fetch_2_3

### Public Instance methods

fetch_2_1(key, options = {}) {|| ...}

[Source]

        # File lib/phusion_passenger/classic_rails_extensions/analytics_logging/as_cache_extension.rb, line 29
    29:         def fetch_2_1(key, options = {})
    30:                 @logger_off = true
    31:                 if !options[:force] && value = read(key, options)
    32:                         @logger_off = false
    33:                         log("hit", key, options)
    34:                         PhusionPassenger.log_cache_hit(nil, key)
    35:                         value
    36:                 elsif block_given?
    37:                         @logger_off = false
    38:                         log("miss", key, options)
    39:
    40:                         value = nil
    41:                         seconds = Benchmark.realtime { value = yield }
    42:
    43:                         @logger_off = true
    44:                         write(key, value, options)
    45:                         @logger_off = false
    46:
    47:                         log("write (will save #{'%.5f' % seconds})", key, nil)
    48:                         PhusionPassenger.log_cache_miss(nil, key, seconds * 1_000_000)
    49:
    50:                         value
    51:                 else
    52:                         PhusionPassenger.log_cache_miss(nil, key)
    53:                         value
    54:                 end
    55:         end

fetch_2_2(key, options = {}) {|| ...}

[Source]

        # File lib/phusion_passenger/classic_rails_extensions/analytics_logging/as_cache_extension.rb, line 57
    57:         def fetch_2_2(key, options = {})
    58:                 @logger_off = true
    59:                 if !options[:force] && value = read(key, options)
    60:                         @logger_off = false
    61:                         log("hit", key, options)
    62:                         PhusionPassenger.log_cache_hit(nil, key)
    63:                         value
    64:                 elsif block_given?
    65:                         @logger_off = false
    66:                         log("miss", key, options)
    67:
    68:                         value = nil
    69:                         seconds = Benchmark.realtime { value = yield }
    70:
    71:                         @logger_off = true
    72:                         write(key, value, options)
    73:                         @logger_off = false
    74:
    75:                         log("write (will save #{'%.2f' % (seconds * 1000)}ms)", key, nil)
    76:                         PhusionPassenger.log_cache_miss(nil, key, seconds * 1_000_000)
    77:
    78:                         value
    79:                 else
    80:                         PhusionPassenger.log_cache_miss(nil, key)
    81:                         value
    82:                 end
    83:         end

fetch_2_3(key, options = {}) {|| ...}

[Source]

         # File lib/phusion_passenger/classic_rails_extensions/analytics_logging/as_cache_extension.rb, line 85
     85:         def fetch_2_3(key, options = {})
     86:                 @logger_off = true
     87:                 if !options[:force] && value = read(key, options)
     88:                         @logger_off = false
     89:                         log("hit", key, options)
     90:                         PhusionPassenger.log_cache_hit(nil, key)
     91:                         value
     92:                 elsif block_given?
     93:                         @logger_off = false
     94:                         log("miss", key, options)
     95:
     96:                         value = nil
     97:                         ms = Benchmark.ms { value = yield }
     98:
     99:                         @logger_off = true
    100:                         write(key, value, options)
    101:                         @logger_off = false
    102:
    103:                         log('write (will save %.2fms)' % ms, key, nil)
    104:                         PhusionPassenger.log_cache_miss(nil, key, ms * 1_000)
    105:
    106:                         value
    107:                 else
    108:                         PhusionPassenger.log_cache_miss(nil, key)
    109:                         value
    110:                 end
    111:         end

[Validate]