sm
/
cache
1
0
Fork 0

make sharded cache unexported back again

This commit is contained in:
Pranjal Pandit 2016-09-13 13:44:46 +05:30
parent 86164a864c
commit b205f45f51
2 changed files with 4 additions and 4 deletions

View File

@ -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
} }

View File

@ -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)