Module: Sinatra::Redis

Defined in:
lib/sinatra/redis.rb

Instance Method Summary collapse

Instance Method Details

#redisObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/sinatra/redis.rb', line 18

def redis
  @redis ||= (
    url = URI(redis_url)

    base_settings = {
      :host => url.host,
      :port => url.port,
      :db => url.path[1..-1],
      :password => url.password
    }

    ::Redis.new(
      base_settings.merge(
        redis_settings
      )
    )
  )
end

#redis=(url) ⇒ Object



12
13
14
15
16
# File 'lib/sinatra/redis.rb', line 12

def redis=(url)
  @redis = nil
  set :redis_url, url
  redis
end