Module: Redisk

Extended by:
Redisk
Included in:
Redisk
Defined in:
lib/redisk/logger.rb,
lib/redisk.rb,
lib/redisk/io.rb,
lib/redisk/stat.rb,
lib/redisk/helper.rb

Overview

Redisk::Log is a wrapper around logger, that uses Redisk::IO internally and provides some extra options

Defined Under Namespace

Modules: Helper Classes: IO, Logger, Stat

Constant Summary collapse

VERSION =
'0.2.2'

Instance Method Summary collapse

Instance Method Details

#io(*args) ⇒ Object



38
39
40
# File 'lib/redisk.rb', line 38

def io(*args)
  Redisk::IO.new(*args)
end

#logger(*args) ⇒ Object



42
43
44
# File 'lib/redisk.rb', line 42

def logger(*args)
  Redisk::Logger.new(*args)
end

#redisObject

Returns the current Redis connection. If none has been created, will create a new one.



32
33
34
35
36
# File 'lib/redisk.rb', line 32

def redis
  return @redis if @redis
  self.redis = 'localhost:6379'
  self.redis
end

#redis=(server) ⇒ Object

straight up lifted from from @defunkt’s resque Accepts a ‘hostname:port’ string or a Redis server.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/redisk.rb', line 15

def redis=(server)
  case server
  when String
    host, port = server.split(':')
    redis = Redis.new(:host => host, :port => port, :thread_safe => true)
    @redis = Redis::Namespace.new(:redisk, :redis => redis)
  when Redis::Namespace
    @redis = server
  when Redis
    @redis = Redis::Namespace.new(:redisk, :redis => server)
  else
    raise "I don't know what to do with #{server.inspect}"
  end
end