mirror of https://github.com/go-redis/redis.git
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…
Reference in New Issue