Sha256: c88f857a40941441216092015f7b96fd48a732666139d5f6b75fc9adea25efcb
Contents?: true
Size: 1.16 KB
Versions: 4
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true require 'delorean/cache/adapters' module Delorean module Cache NODE_CACHE_DEFAULT_CALLBACK = lambda do |klass:, method:, params:| { cache: true, } end class << self attr_accessor :adapter def with_cache(klass:, method:, mutable_params:, params:) delorean_cache_adapter = ::Delorean::Cache.adapter klass_name = "#{klass.name}#{::Delorean::POST}" cache_options = node_cache_callback.call( klass: klass, method: method, params: mutable_params ) return yield unless cache_options[:cache] cache_key = delorean_cache_adapter.cache_key( klass: klass_name, method_name: method, args: [params] ) cached_item = delorean_cache_adapter.fetch_item( klass: klass_name, cache_key: cache_key, default: :NF ) return cached_item if cached_item != :NF res = yield delorean_cache_adapter.cache_item( klass: klass_name, cache_key: cache_key, item: res, ) res end attr_accessor :node_cache_callback end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
delorean_lang-2.5.0 | lib/delorean/cache.rb |
delorean_lang-2.4.2 | lib/delorean/cache.rb |
delorean_lang-2.4.0 | lib/delorean/cache.rb |
delorean_lang-2.3.0 | lib/delorean/cache.rb |