fix: keep Redis timeouts below a second exact
A checker's long poll ends with BLPOP waiting the rest of it, often below a second, which go-redis rounded up to one second with a warning in the log; the poll then ran up to a second too long. Such waits now pass BLPOP a fraction of a second, which Redis takes since 6.0. A session's sliding expiry, which can be below a second near its absolute end, uses PEXPIRE. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
db36d918fe
commit
66537f4e65
3 files changed
+28
-3
No files matched your search
@@ -152,7 +152,8 @@ func (s *Sessions) Get(ctx context.Context, token string) (*Session, error) {
|
||||
}
|
||||
// Sliding expiry, but never beyond the absolute lifetime.
|
||||
remaining := s.absolute - s.now().Sub(sess.CreatedAt)
|
||||
if err := s.rdb.Expire(ctx, k, min(s.idle, remaining)).Err(); err != nil {
|
||||
// PEXPIRE: the rest of the lifetime may be below a second.
|
||||
if err := s.rdb.PExpire(ctx, k, min(s.idle, remaining)).Err(); err != nil {
|
||||
return nil, fmt.Errorf("auth: touch session: %w", err)
|
||||
}
|
||||
return sess, nil
|
||||
|
||||
Reference in new issue
Block a user