class WorkflowManager::Server::RedisDB

Attributes

port[RW]

Public Class Methods

new(db_no=0, redis_conf) click to toggle source
# File lib/workflow_manager/server.rb, line 115
def initialize(db_no=0, redis_conf)
  if db_no==0
    run_redis_server(redis_conf)
  end
  conf = Hash[*CSV.readlines(redis_conf, col_sep: " ").map{|a| [a.first, a[1,100].join(",")]}.flatten]
  @port = (conf["port"]||6379).to_i
  @db = Redis.new(port: @port, db: db_no)
end

Public Instance Methods

run_redis_server(redis_conf) click to toggle source
# File lib/workflow_manager/server.rb, line 107
def run_redis_server(redis_conf)
  @pid = fork do
    exec("redis-server #{redis_conf}")
  end
  @redis_thread = Thread.new do
    Process.waitpid @pid
  end
end
transaction() { |db| ... } click to toggle source
# File lib/workflow_manager/server.rb, line 123
def transaction
  #@db.multi do
    yield(@db)
  #end
end