Sha256: cfa1fbc2abc0bc3338ae0a8e2b7cf388d911e7a9b7549ee609a736c42cd43e25
Contents?: true
Size: 846 Bytes
Versions: 10
Compression:
Stored size: 846 Bytes
Contents
module JSONAPIonify::Api module Resource::Caching def cache key, **options raise Errors::DoubleCacheError, "Cache was already called for this action" if @cache_called @cache_called = true @cache_options.merge! options # Build the cache key, and obscure it. @__context.meta[:cache_key] = @cache_options[:key] = cache_key( path: @__context.request.path, accept: @__context.request.accept, params: @__context.params, key: key ) # If the cache exists, then fail to cache miss if self.class.cache_store.exist?(@cache_options[:key]) && !@__context.invalidate_cache? raise Errors::CacheHit, @cache_options[:key] end end def cache_key(**options) self.class.cache_key(**options, action_name: @__context.action_name) end end end
Version data entries
10 entries across 10 versions & 1 rubygems