Merge a62604383c
into 46f4078530
This commit is contained in:
commit
d15f910d83
|
@ -7,3 +7,4 @@ Dustin Sallings <dustin@spy.net>
|
|||
Jason Mooberry <jasonmoo@me.com>
|
||||
Sergey Shepelev <temotor@gmail.com>
|
||||
Alex Edwards <ajmedwards@gmail.com>
|
||||
Dmitry Medvedev <mr.vidmed@gmail.com>
|
||||
|
|
|
@ -1762,8 +1762,12 @@ func TestGetWithExpiration(t *testing.T) {
|
|||
} else if e2 := x.(int); e2+2 != 3 {
|
||||
t.Error("e (which should be 1) plus 2 does not equal 3; value:", e2)
|
||||
}
|
||||
if expiration.UnixNano() != tc.items["e"].Expiration {
|
||||
t.Error("expiration for e is not the correct time")
|
||||
tmp, ok := tc.items.Load("e")
|
||||
if ok {
|
||||
e := tmp.(Item)
|
||||
if expiration.UnixNano() != e.Expiration {
|
||||
t.Error("expiration for e is not the correct time")
|
||||
}
|
||||
}
|
||||
if expiration.UnixNano() < time.Now().UnixNano() {
|
||||
t.Error("expiration for e is in the past")
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"os"
|
||||
"runtime"
|
||||
"time"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// This is an experimental and unexported (for now) attempt at making a cache
|
||||
|
@ -171,7 +172,7 @@ func newShardedCache(n int, de time.Duration) *shardedCache {
|
|||
for i := 0; i < n; i++ {
|
||||
c := &cache{
|
||||
defaultExpiration: de,
|
||||
items: map[string]Item{},
|
||||
items: sync.Map{},
|
||||
}
|
||||
sc.cs[i] = c
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue