In my code to reuse the redis connection across multiple URL route, is this the correct way to define instance for a single threaded in Redis?
class Red
@conn ||= H2O::Redis.new(:host => '127.0.0.1', :port => 6379)
class << self
attr_reader :conn
end
end
e.g. Route "/set"
require "/www/test.rb"
redis = Red.conn
redis.set(...)
e.g. Route "/get"
require "/www/test.rb"
redis = Red.conn
redis.get(...)