runable
This commit is contained in:
@@ -39,12 +39,14 @@ func (d *redisDedup) CheckAndSet(ctx context.Context, workspaceID, messageID str
|
||||
Ex(d.ttl).
|
||||
Build()
|
||||
resp := d.client.Do(ctx, cmd)
|
||||
if err := resp.Error(); err != nil {
|
||||
return false, fmt.Errorf("dedup setnx: %w", err)
|
||||
}
|
||||
// SET with NX returns "OK" when set, nil reply when key already exists.
|
||||
if resp.IsNil() {
|
||||
err := resp.Error()
|
||||
// SET NX returns nil reply when the key already exists; rueidis surfaces
|
||||
// that as a "redis nil" error, which is *not* a real failure.
|
||||
if rueidis.IsRedisNil(err) {
|
||||
return false, nil
|
||||
}
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("dedup setnx: %w", err)
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user