Class: Memodis::LocalRedisController

Inherits:
Object
  • Object
show all
Defined in:
lib/memodis/local_redis_controller.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_file) ⇒ LocalRedisController

Returns a new instance of LocalRedisController.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/memodis/local_redis_controller.rb', line 13

def initialize(config_file)
  config = IO.readlines(config_file)
  config.reject!  { |l| l !~ /^(bind|port|pidfile|logfile)[ \t]?/ }
  config.collect! { |l| l.chomp.split(/[ \t]/) }
  config.flatten!
  config = Hash[*config]
  config['file'] = config_file
  @config = config
  @config.freeze

  @controller = DaemonController.new({
    :identifier => identifier,
    :start_command => start_command,
    :ping_command => ping_command,
    :pid_file => pid_file,
    :log_file => log_file
  })
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



11
12
13
# File 'lib/memodis/local_redis_controller.rb', line 11

def config
  @config
end

#controllerObject (readonly)

Returns the value of attribute controller.



11
12
13
# File 'lib/memodis/local_redis_controller.rb', line 11

def controller
  @controller
end

Class Method Details

.start(config_file) ⇒ Object



7
8
9
# File 'lib/memodis/local_redis_controller.rb', line 7

def self.start(config_file)
  new(config_file).start
end

Instance Method Details

#connectObject Also known as: start



32
33
34
# File 'lib/memodis/local_redis_controller.rb', line 32

def connect
  @controller.connect { TCPSocket.new(@config['bind'], @config['port']) }
end