Module: Redmon::Redis

Extended by:
Redis
Included in:
Helpers, Redis, Worker
Defined in:
lib/redmon/redis.rb

Constant Summary collapse

UNSUPPORTED =
[
  :eval,
  :psubscribe,
  :punsubscribe,
  :subscribe,
  :unsubscribe,
  :unwatch,
  :watch
]

Instance Method Summary collapse

Instance Method Details

#configObject



33
34
35
# File 'lib/redmon/redis.rb', line 33

def config
  redis.config :get, '*' rescue {}
end

#connection_refusedObject



57
58
59
# File 'lib/redmon/redis.rb', line 57

def connection_refused
  "Could not connect to Redis at #{redis_url.gsub(/\w*:\/\//, '')}: Connection refused"
end

#empty_resultObject



45
46
47
# File 'lib/redmon/redis.rb', line 45

def empty_result
  '(empty list or set)'
end

#nsObject



21
22
23
# File 'lib/redmon/redis.rb', line 21

def ns
  Redmon.config.namespace
end

#redisObject



17
18
19
# File 'lib/redmon/redis.rb', line 17

def redis
  @redis ||= ::Redis.connect(:url => Redmon.config.redis_url)
end

#redis_hostObject



29
30
31
# File 'lib/redmon/redis.rb', line 29

def redis_host
  redis_url.gsub('redis://', '')
end

#redis_urlObject



25
26
27
# File 'lib/redmon/redis.rb', line 25

def redis_url
  @redis_url ||= Redmon.config.redis_url.gsub(/\w*:\w*@/, '')
end

#stats_keyObject



61
62
63
# File 'lib/redmon/redis.rb', line 61

def stats_key
  "#{ns}:redis:#{redis_host}:stats"
end

#supported?(cmd) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/redmon/redis.rb', line 41

def supported?(cmd)
  !UNSUPPORTED.include? cmd
end

#unknown(cmd) ⇒ Object



49
50
51
# File 'lib/redmon/redis.rb', line 49

def unknown(cmd)
  "(error) ERR unknown command '#{cmd}'"
end

#unquotedObject



37
38
39
# File 'lib/redmon/redis.rb', line 37

def unquoted
  %w{string OK} << '(empty list or set)'
end

#wrong_number_of_arguments_for(cmd) ⇒ Object



53
54
55
# File 'lib/redmon/redis.rb', line 53

def wrong_number_of_arguments_for(cmd)
  "(error) ERR wrong number of arguments for '#{cmd}' command"
end