module Rack::AcornCache::Storage

Public Class Methods

memcached() click to toggle source
# File lib/acorn_cache/storage.rb, line 16
def self.memcached
  options = {}

  if ENV["ACORNCACHE_MEMCACHED_USERNAME"]
    options = { username: ENV["ACORNCACHE_MEMCACHED_USERNAME"],
                password: ENV["ACORNCACHE_MEMCACHED_PASSWORD"] }
  end

  @memcached ||= Dalli::Client.new(ENV["ACORNCACHE_MEMCACHED_URL"], options)
end
redis() click to toggle source
# File lib/acorn_cache/storage.rb, line 6
def self.redis
  args = { host: ENV["ACORNCACHE_REDIS_HOST"],
           port: ENV["ACORNCACHE_REDIS_PORT"].to_i }
  if ENV["ACORNCACHE_REDIS_PASSWORD"]
    args.merge!(password: ENV["ACORNCACHE_REDIS_PASSWORD"])
  end

  @redis ||= Redis.new(args)
end