Skip to content

Commit

Permalink
fix: Use redis pipeline for DeleteJob in redis reuslts store. (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamd3vil authored Mar 12, 2024
1 parent ef1da2b commit e2d7d2b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions results/redis/results.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit e2d7d2b

Please sign in to comment.