Class: ApiBlueprint::Cache

Inherits:
Object
  • Object
show all
Extended by:
Dry::Configurable, Dry::Initializer
Defined in:
lib/api-blueprint/cache.rb

Instance Method Summary collapse

Instance Method Details

#exist?(id) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/api-blueprint/cache.rb', line 10

def exist?(id)
  false
end

#generate_cache_key(klass, options) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/api-blueprint/cache.rb', line 22

def generate_cache_key(klass, options)
  if klass&.cache_key_generator&.present?
    klass.cache_key_generator.call key, options
  else
    if options.is_a? Hash
      options = options.clone.with_indifferent_access.except :body
      options[:headers] = options[:headers].except *self.class.config.ignored_headers if options[:headers]
    end

    options_digest = Digest::MD5.hexdigest Marshal::dump(options.to_s.chars.sort.join)
    "#{key}:#{klass&.name}:#{options_digest}"
  end
end

#read(id) ⇒ Object



14
15
16
# File 'lib/api-blueprint/cache.rb', line 14

def read(id)
  false
end

#write(id, data, options) ⇒ Object



18
19
20
# File 'lib/api-blueprint/cache.rb', line 18

def write(id, data, options)
  data
end