[Why] A redis pool is created for each HTTP request. This is wrong. This can cause too many connections to be established. All HTTP requests should share a redis pool.
[How] Use singleton pattern
Signed-off-by: Wu Zhende wuzhende666@163.com --- src/lib/sched.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/lib/sched.cr b/src/lib/sched.cr index f46d97c..b90759f 100644 --- a/src/lib/sched.cr +++ b/src/lib/sched.cr @@ -32,7 +32,7 @@ class Sched
def initialize(env : HTTP::Server::Context) @es = Elasticsearch::Client.new - @redis = Redis::Client.new + @redis = Redis::Client.instance @task_queue = TaskQueueAPI.new @rgc = RemoteGitClient.new @env = env