Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# encoding: utf-8
module Prismic
class Memcache
def initialize(max_size=100)
end
def set(key, value, expired_in = nil)
Rails.cache.write(key, value, :expires_in => expired_in = expired_in && Time.now.getutc.to_i + expired_in)
value
end
def []=(key, value)
set(key, value, nil)
end
def get(key)
Rails.cache.read(key)
end
alias :[] :get
def get_or_set(key, value = nil, expired_in = nil)
Rails.cache.fetch(key, :expires_in => expired_in = expired_in && Time.now.getutc.to_i + expired_in) { block_given? ? yield : value }
end
def delete(key)
Rails.cache.delete(key)
nil
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.