change function time.Duration.Milliseconds to time.Duration.Nanoseconds for compatibility of Golang version < 1.13

This commit is contained in:
John
2020-03-16 23:03:37 +08:00
parent c7f911cae2
commit 2b46e765c4
2 changed files with 2 additions and 2 deletions

View File

@ -82,7 +82,7 @@ func (p *Pool) Put(value interface{}) error {
if p.TTL == 0 {
item.expire = 0
} else {
// As for Golang version <= 1.13, there's no method Milliseconds for time.Duration.
// As for Golang version < 1.13, there's no method Milliseconds for time.Duration.
// So we need calculate the milliseconds using its nanoseconds value.
item.expire = gtime.TimestampMilli() + p.TTL.Nanoseconds()/1000000
}

View File

@ -141,7 +141,7 @@ func (l *Logger) rotateChecks() {
// Expiration checks.
if l.config.RotateExpire > 0 {
nowTimestampMilli := gtime.TimestampMilli()
// As for Golang version <= 1.13, there's no method Milliseconds for time.Duration.
// As for Golang version < 1.13, there's no method Milliseconds for time.Duration.
// So we need calculate the milliseconds using its nanoseconds value.
expireMillisecond := l.config.RotateExpire.Nanoseconds() / 1000000
for _, array := range backupFilesMap {