Module: Rack::AcornCache::Storage

Defined in:
lib/acorn_cache/storage.rb

Class Method Summary collapse

Class Method Details

.memcachedObject



16
17
18
19
20
21
22
23
24
25
# 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

.redisObject



6
7
8
9
10
11
12
13
14
# 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