Module: AnyCache::Patches::DalliStore::ActiveSupportFetchWithKey Private
- Defined in:
- lib/any_cache/patches/dalli_store.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
-
#fetch(name, options = nil) ⇒ Object
private
NOTE: original fetch implementation with my own little fix (see #43 line of code below) rubocop:disable all.
Instance Method Details
#fetch(name, options = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
NOTE: original fetch implementation with my own little fix (see #43 line of code below) rubocop:disable all
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/any_cache/patches/dalli_store.rb', line 24 def fetch(name, =nil) ||= {} [:cache_nils] = true if @options[:cache_nils] namespaced_name = namespaced_key(name, ) not_found = [:cache_nils] ? Dalli::Server::NOT_FOUND : nil if block_given? entry = not_found unless [:force] entry = instrument_with_log(:read, namespaced_name, ) do |payload| read_entry(namespaced_name, ).tap do |result| if payload payload[:super_operation] = :fetch payload[:hit] = not_found != result end end end end if not_found == entry result = instrument_with_log(:generate, namespaced_name, ) do |payload| # FIX: https://github.com/petergoldstein/dalli/pull/701 yield(name) # FIX: https://github.com/petergoldstein/dalli/pull/701 end write(name, result, ) result else instrument_with_log(:fetch_hit, namespaced_name, ) { |payload| } entry end else read(name, ) end end |