mirror of
https://github.com/redis/go-redis.git
synced 2025-04-17 20:17:02 +03:00
Fix race in tests.
This commit is contained in:
parent
673e999431
commit
4edc7a059c
@ -2,6 +2,7 @@ package redis
|
||||
|
||||
import (
|
||||
"net"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -19,12 +20,18 @@ func (cn *conn) SetNetConn(netcn net.Conn) {
|
||||
cn.netcn = netcn
|
||||
}
|
||||
|
||||
var timeMu sync.Mutex
|
||||
|
||||
func SetTime(tm time.Time) {
|
||||
timeMu.Lock()
|
||||
now = func() time.Time {
|
||||
return tm
|
||||
}
|
||||
timeMu.Unlock()
|
||||
}
|
||||
|
||||
func RestoreTime() {
|
||||
timeMu.Lock()
|
||||
now = time.Now
|
||||
timeMu.Unlock()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user