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.
115 116 117 118 119 120 121 122 |
# 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 |
Instance Attribute Details
#port ⇒ Object
Returns the value of attribute port.
106 107 108 |
# File 'lib/workflow_manager/server.rb', line 106 def port @port end |
Instance Method Details
#run_redis_server(redis_conf) ⇒ Object
107 108 109 110 111 112 113 114 |
# 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| ... } ⇒ Object
123 124 125 126 127 |
# File 'lib/workflow_manager/server.rb', line 123 def transaction #@db.multi do yield(@db) #end end |