module Ampere

The Ampere module contains methods to connect/disconnect and gives access to the Redis connection directly (though you really shouldn’t need to use it).

require ‘pp’

Public Class Methods

connect(options = {}) click to toggle source

Open a new Redis connection. ‘options` is passed directly to the Redis.connect method.

# File lib/ampere.rb, line 11
def self.connect(options = {})
  @@connection = Redis.connect(options)
end
connected?() click to toggle source

Returns ‘true` if the Redis connection is active.

# File lib/ampere.rb, line 23
def self.connected?
  !! @@connection
end
connection() click to toggle source

Gives access to the Redis connection object.

# File lib/ampere.rb, line 28
def self.connection
  @@connection
end
disconnect() click to toggle source

Closes the Redis connection.

# File lib/ampere.rb, line 16
def self.disconnect
  return unless connected?
  @@connection.quit
  @@connection = nil
end
flush() click to toggle source

Alias for Ampere.redis.flushall

# File lib/ampere.rb, line 33
def self.flush
  @@connection.flushall if connected?
end