File tree Expand file tree Collapse file tree 1 file changed +5
-16
lines changed Expand file tree Collapse file tree 1 file changed +5
-16
lines changed Original file line number Diff line number Diff line change 7
7
"os"
8
8
"runtime"
9
9
"sync"
10
- "syscall"
11
10
"time"
12
11
)
13
12
@@ -21,9 +20,7 @@ func (item Item) Expired() bool {
21
20
if item .Expiration == 0 {
22
21
return false
23
22
}
24
- var tv syscall.Timeval
25
- syscall .Gettimeofday (& tv )
26
- return tv .Nano () > item .Expiration
23
+ return time .Now ().UnixNano () > item .Expiration
27
24
}
28
25
29
26
const (
@@ -112,9 +109,7 @@ func (c *cache) Get(k string) (interface{}, bool) {
112
109
return nil , false
113
110
}
114
111
if item .Expiration > 0 {
115
- var tv syscall.Timeval
116
- syscall .Gettimeofday (& tv )
117
- if tv .Nano () > item .Expiration {
112
+ if time .Now ().UnixNano () > item .Expiration {
118
113
c .mu .RUnlock ()
119
114
return nil , false
120
115
}
@@ -130,9 +125,7 @@ func (c *cache) get(k string) (interface{}, bool) {
130
125
}
131
126
// "Inlining" of Expired
132
127
if item .Expiration > 0 {
133
- var tv syscall.Timeval
134
- syscall .Gettimeofday (& tv )
135
- if tv .Nano () > item .Expiration {
128
+ if time .Now ().UnixNano () > item .Expiration {
136
129
c .mu .RUnlock ()
137
130
return nil , false
138
131
}
@@ -890,12 +883,8 @@ type keyAndValue struct {
890
883
891
884
// Delete all expired items from the cache.
892
885
func (c * cache ) DeleteExpired () {
893
- var (
894
- evictedItems []keyAndValue
895
- tv syscall.Timeval
896
- )
897
- syscall .Gettimeofday (& tv )
898
- now := tv .Nano ()
886
+ var evictedItems []keyAndValue
887
+ now := time .Now ().UnixNano ()
899
888
c .mu .Lock ()
900
889
for k , v := range c .items {
901
890
// "Inlining" of expired
You can’t perform that action at this time.
0 commit comments