Module: Redmon::Redis
Constant Summary collapse
- UNSUPPORTED =
[ :eval, :psubscribe, :punsubscribe, :subscribe, :unsubscribe, :unwatch, :watch ]
Instance Method Summary collapse
- #config ⇒ Object
- #connection_refused ⇒ Object
- #empty_result ⇒ Object
- #ns ⇒ Object
- #redis ⇒ Object
- #redis_host ⇒ Object
- #redis_url ⇒ Object
- #stats_key ⇒ Object
- #supported?(cmd) ⇒ Boolean
- #unknown(cmd) ⇒ Object
- #unquoted ⇒ Object
- #wrong_number_of_arguments_for(cmd) ⇒ Object
Instance Method Details
#config ⇒ Object
33 34 35 |
# File 'lib/redmon/redis.rb', line 33 def config redis.config :get, '*' rescue {} end |
#connection_refused ⇒ Object
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_result ⇒ Object
45 46 47 |
# File 'lib/redmon/redis.rb', line 45 def empty_result '(empty list or set)' end |
#redis ⇒ Object
17 18 19 |
# File 'lib/redmon/redis.rb', line 17 def redis @redis ||= ::Redis.connect(:url => Redmon.config.redis_url) end |
#redis_host ⇒ Object
29 30 31 |
# File 'lib/redmon/redis.rb', line 29 def redis_host redis_url.gsub('redis://', '') end |
#redis_url ⇒ Object
25 26 27 |
# File 'lib/redmon/redis.rb', line 25 def redis_url @redis_url ||= Redmon.config.redis_url.gsub(/\w*:\w*@/, '') end |
#stats_key ⇒ Object
61 62 63 |
# File 'lib/redmon/redis.rb', line 61 def stats_key "#{ns}:redis:#{redis_host}:stats" end |
#supported?(cmd) ⇒ 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 |
#unquoted ⇒ Object
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 |