Class: WorkflowManager::Server::RedisDB
- Inherits:
-
Object
- Object
- WorkflowManager::Server::RedisDB
- Defined in:
- lib/workflow_manager/server.rb
Instance Attribute Summary collapse
-
#port ⇒ Object
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(db_no = 0, redis_conf) ⇒ RedisDB
constructor
A new instance of RedisDB.
- #run_redis_server(redis_conf) ⇒ Object
- #transaction {|@db| ... } ⇒ Object
Constructor Details
#initialize(db_no = 0, redis_conf) ⇒ RedisDB
Returns a new instance of RedisDB.
112 113 114 115 116 117 118 119 |
# File 'lib/workflow_manager/server.rb', line 112 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 |
Instance Attribute Details
#port ⇒ Object
Returns the value of attribute port.
103 104 105 |
# File 'lib/workflow_manager/server.rb', line 103 def port @port end |
Instance Method Details
#run_redis_server(redis_conf) ⇒ Object
104 105 106 107 108 109 110 111 |
# File 'lib/workflow_manager/server.rb', line 104 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| ... } ⇒ Object
120 121 122 123 124 |
# File 'lib/workflow_manager/server.rb', line 120 def transaction #@db.multi do yield(@db) #end end |