Class: Cloudinary::Cache::RailsCacheAdapter

Inherits:
CacheAdapter
  • Object
show all
Defined in:
lib/cloudinary/cache/rails_cache_adapter.rb

Instance Method Summary collapse

Instance Method Details

#fetch(public_id, type, resource_type, transformation, format) ⇒ Object



23
24
25
26
# File 'lib/cloudinary/cache/rails_cache_adapter.rb', line 23

def fetch(public_id, type, resource_type, transformation, format)
  key = generate_cache_key(public_id, type, resource_type, transformation, format)
  Rails.cache.fetch(key, &Proc.new)
end

#flush_allObject



4
5
# File 'lib/cloudinary/cache/rails_cache_adapter.rb', line 4

def flush_all
end

#get(public_id, type, resource_type, transformation, format) ⇒ Object



7
8
9
10
# File 'lib/cloudinary/cache/rails_cache_adapter.rb', line 7

def get(public_id, type, resource_type, transformation, format)
  key = generate_cache_key(public_id, type, resource_type, transformation, format)
  Rails.cache.read(key)
end

#initObject



12
13
14
15
16
# File 'lib/cloudinary/cache/rails_cache_adapter.rb', line 12

def init
  unless defined? Rails
    raise CloudinaryException.new "Rails is required in order to use RailsCacheAdapter"
  end
end

#set(public_id, type, resource_type, transformation, format, value) ⇒ Object



18
19
20
21
# File 'lib/cloudinary/cache/rails_cache_adapter.rb', line 18

def set(public_id, type, resource_type, transformation, format, value)
  key = generate_cache_key(public_id, type, resource_type, transformation, format)
  Rails.cache.write(key, value)
end