lib/modules/backend.rb in redis_monitor-0.0.3 vs lib/modules/backend.rb in redis_monitor-0.0.4
- old
+ new
@@ -1,10 +1,16 @@
require 'redis'
require 'errors/errors'
+require 'modules/performance_stats'
+require 'forwardable'
module RedisMonitor
class Backend
+ extend SingleForwardable
+
+ def_delegators :redis, :get, :set, :del, :info, :keys, :dbsize
+
def self.config(arguments)
@@host = arguments[:redis_host]
@@port = arguments[:redis_port]
end
@@ -14,24 +20,14 @@
def self.port
@@port
end
- def self.ensure_connected(redis)
- begin
- redis.ping
- rescue Redis::CannotConnectError => e
- raise RedisMonitor::Errors::RedisNotAvailable
- end
- end
-
def self.redis
- redis = Redis.new(:host => host, :port => port)
- ensure_connected(redis)
- redis
+ @@redis ||= Redis.new(:host => host, :port => port)
end
- def self.info
- redis.info
+ def self.performance_stats
+ PerformanceStats.new(self).results
end
end
end
\ No newline at end of file