Sha256: 3199d33326cafb9037cb5e38341fc0818704a992e7cbe8eb64efc71d78e03921
Contents?: true
Size: 508 Bytes
Versions: 1
Compression:
Stored size: 508 Bytes
Contents
# frozen_string_literal: true require "active_support/cache" require "active_support/notifications" module Dphil module_function def cache(key, params = nil) @cache ||= defined?(::Rails.cache) ? ::Rails.cache : ActiveSupport::Cache::MemoryStore.new(size: 16_384) full_key = String.new("Dphil-#{Dphil::VERSION}:cache:#{key}") full_key << ":#{Digest::SHA1.base64digest(params.to_s)}" unless params.nil? block_given? ? @cache.fetch(full_key, &Proc.new) : @cache.fetch(full_key) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dphil-0.1.4 | lib/dphil/cache.rb |