make sharded cache unexported back again
This commit is contained in:
parent
86164a864c
commit
b205f45f51
|
@ -178,7 +178,7 @@ func newShardedCache(n int, de time.Duration) *shardedCache {
|
||||||
return sc
|
return sc
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSharded(defaultExpiration, cleanupInterval time.Duration, shards int) *unexportedShardedCache {
|
func newSharded(defaultExpiration, cleanupInterval time.Duration, shards int) *unexportedShardedCache {
|
||||||
if defaultExpiration == 0 {
|
if defaultExpiration == 0 {
|
||||||
defaultExpiration = -1
|
defaultExpiration = -1
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ var shardedKeys = []string{
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestShardedCache(t *testing.T) {
|
func TestShardedCache(t *testing.T) {
|
||||||
tc := NewSharded(DefaultExpiration, 0, 13)
|
tc := newSharded(DefaultExpiration, 0, 13)
|
||||||
for _, v := range shardedKeys {
|
for _, v := range shardedKeys {
|
||||||
tc.Set(v, "value", DefaultExpiration)
|
tc.Set(v, "value", DefaultExpiration)
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ func BenchmarkShardedCacheGetNotExpiring(b *testing.B) {
|
||||||
|
|
||||||
func benchmarkShardedCacheGet(b *testing.B, exp time.Duration) {
|
func benchmarkShardedCacheGet(b *testing.B, exp time.Duration) {
|
||||||
b.StopTimer()
|
b.StopTimer()
|
||||||
tc := NewSharded(exp, 0, 10)
|
tc := newSharded(exp, 0, 10)
|
||||||
tc.Set("foobarba", "zquux", DefaultExpiration)
|
tc.Set("foobarba", "zquux", DefaultExpiration)
|
||||||
b.StartTimer()
|
b.StartTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
|
@ -62,7 +62,7 @@ func BenchmarkShardedCacheGetManyConcurrentNotExpiring(b *testing.B) {
|
||||||
func benchmarkShardedCacheGetManyConcurrent(b *testing.B, exp time.Duration) {
|
func benchmarkShardedCacheGetManyConcurrent(b *testing.B, exp time.Duration) {
|
||||||
b.StopTimer()
|
b.StopTimer()
|
||||||
n := 10000
|
n := 10000
|
||||||
tsc := NewSharded(exp, 0, 20)
|
tsc := newSharded(exp, 0, 20)
|
||||||
keys := make([]string, n)
|
keys := make([]string, n)
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
k := "foo" + strconv.Itoa(n)
|
k := "foo" + strconv.Itoa(n)
|
||||||
|
|
Loading…
Reference in New Issue