This commit is contained in:
2026-05-25 10:16:31 +07:00
parent a428170fef
commit c5e980aa52
21 changed files with 6172 additions and 102 deletions

View File

@@ -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
}