From 39eb573fff4422bc12a6441174ac1ec39aa019ba Mon Sep 17 00:00:00 2001 From: Sarat Chandra Date: Tue, 12 Mar 2024 11:56:05 +0530 Subject: [PATCH] fix: Use redis pipeline for DeleteJob in redis reuslts store. --- results/redis/results.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/results/redis/results.go b/results/redis/results.go index e65e9f0..968e6df 100644 --- a/results/redis/results.go +++ b/results/redis/results.go @@ -72,15 +72,21 @@ func New(o Options, lo *slog.Logger) *Results { func (r *Results) DeleteJob(ctx context.Context, id string) error { r.lo.Debug("deleting job") - if err := r.conn.ZRem(ctx, resultPrefix+success, 1, id).Err(); err != nil { + + pipe := r.conn.Pipeline() + if err := pipe.ZRem(ctx, resultPrefix+success, 1, id).Err(); err != nil { + return err + } + + if err := pipe.ZRem(ctx, resultPrefix+failed, 1, id).Err(); err != nil { return err } - if err := r.conn.ZRem(ctx, resultPrefix+failed, 1, id).Err(); err != nil { + if err := pipe.Del(ctx, resultPrefix+id).Err(); err != nil { return err } - if err := r.conn.Del(ctx, resultPrefix+id).Err(); err != nil { + if _, err := pipe.Exec(ctx); err != nil { return err }