3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/jsonapionify/api/resource/caching.rb', line 3
def cache key, **options
raise Errors::DoubleCacheError, "Cache was already called for this action" if @cache_called
@cache_called = true
@cache_options.merge! options
@__context.meta[:cache_key] = @cache_options[:key] = cache_key(
path: @__context.request.path,
accept: @__context.request.accept,
params: @__context.params,
key: key
)
if self.class.cache_store.exist?(@cache_options[:key]) && !@__context.invalidate_cache?
raise Errors::CacheHit, @cache_options[:key]
end
end
|