From 8b0f566e4faf09f62b14d9994e3c3ee294065bef Mon Sep 17 00:00:00 2001 From: Fosco Marotto Date: Sat, 16 Jan 2021 13:36:19 -0500 Subject: [PATCH] [redis] Example change to redis pooling code. --- app/controllers/admin/expenses_controller.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/expenses_controller.rb b/app/controllers/admin/expenses_controller.rb index bbe1b33b..5be43ed4 100644 --- a/app/controllers/admin/expenses_controller.rb +++ b/app/controllers/admin/expenses_controller.rb @@ -1,10 +1,14 @@ class Admin::ExpensesController < Admin::BaseController def index - @amount = Redis.current.get("monthly_funding_amount") || 0 + Redis.current.with do |conn| + @amount = conn.get("monthly_funding_amount") || 0 + end end def create - Redis.current.set("monthly_funding_amount", params[:amount]) + Redis.current.with do |conn| + conn.set("monthly_funding_amount", params[:amount]) + end redirect_to admin_expenses_path end