mirror of
https://github.com/redis/go-redis.git
synced 2025-04-19 07:22:17 +03:00
* Remove OpenTelemetry from the code (but leave redisotel as is) (#1782) * Add XAutoClaim command (#1780) * fix typo (#1788) * xgroup/xadd/xtrim supports new options (#1787) * support cmd option XGROUP CREATECONSUMER XTRIM MINID LIMIT XADD NOMKSTREAM MINID LIMIT Signed-off-by: monkey <golang@88.com> * add XAddArgs.Approx doc Signed-off-by: monkey92t <golang@88.com> * Add Bun to readme * Upgrade the <sorted set> series of commands (#1792) * Upgrade the <sorted set> series of commands Signed-off-by: monkey92t <golang@88.com> * Cancel the Deprecated mark of ZAddNX and ZAddXX Signed-off-by: monkey92t <golang@88.com> * Explain the use restrictions of KeepTTL. (#1799) Signed-off-by: monkey92t <golang@88.com> * Adjust KeepTTL annotation. Signed-off-by: monkey92t <golang@88.com> * the hello command throws possible errors, It may affect the "read timeout" test result. Signed-off-by: monkey92t <golang@88.com> Co-authored-by: Vladimir Mihailenco <vladimir.webdev@gmail.com> Co-authored-by: ericmillin <31105612+ericmillin@users.noreply.github.com> Co-authored-by: heyanfu <1145291570@qq.com>
47 lines
637 B
Go
47 lines
637 B
Go
package internal
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/go-redis/redis/v8/internal/util"
|
|
)
|
|
|
|
func Sleep(ctx context.Context, dur time.Duration) error {
|
|
t := time.NewTimer(dur)
|
|
defer t.Stop()
|
|
|
|
select {
|
|
case <-t.C:
|
|
return nil
|
|
case <-ctx.Done():
|
|
return ctx.Err()
|
|
}
|
|
}
|
|
|
|
func ToLower(s string) string {
|
|
if isLower(s) {
|
|
return s
|
|
}
|
|
|
|
b := make([]byte, len(s))
|
|
for i := range b {
|
|
c := s[i]
|
|
if c >= 'A' && c <= 'Z' {
|
|
c += 'a' - 'A'
|
|
}
|
|
b[i] = c
|
|
}
|
|
return util.BytesToString(b)
|
|
}
|
|
|
|
func isLower(s string) bool {
|
|
for i := 0; i < len(s); i++ {
|
|
c := s[i]
|
|
if c >= 'A' && c <= 'Z' {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|