module Cloudinary::Cache

Attributes

storage[RW]

Public Class Methods

fetch(public_id, options)
Alias for: get
flush_all() click to toggle source
# File lib/cloudinary/cache.rb, line 23
def flush_all
  storage.clear
end
get(public_id, options) { || ... } click to toggle source
# File lib/cloudinary/cache.rb, line 9
def get(public_id, options)
  if block_given?
    storage.read(generate_cache_key(public_id, options)) {yield}
  else
    storage.read(generate_cache_key(public_id, options))
  end
end
Also aliased as: fetch
set(public_id, options, value) click to toggle source
# File lib/cloudinary/cache.rb, line 17
def set(public_id, options, value)
  storage.write(generate_cache_key(public_id, options), value)
end

Private Class Methods

generate_cache_key(public_id, options) click to toggle source
# File lib/cloudinary/cache.rb, line 29
def generate_cache_key(public_id, options)
  type = options[:type] || "upload"
  resource_type = options[:resource_type] || "image"
  transformation = Cloudinary::Utils.generate_transformation_string options.clone
  format = options[:format]
  Digest::SHA1.hexdigest [public_id, type, resource_type, transformation, format].reject(&:blank?).join('/')
end