improve and simplify repository caching

This commit is contained in:
Brad Rydzewski
2016-03-04 21:15:50 -08:00
parent 6769eed65d
commit 3dd0260b69
15 changed files with 444 additions and 364 deletions

10
cache/cache.go vendored
View File

@@ -1,5 +1,7 @@
package cache
//go:generate mockery -name Cache -output mock -case=underscore
import (
"time"
@@ -23,7 +25,7 @@ func Set(c context.Context, key string, value interface{}) error {
// Default creates an in-memory cache with the default
// 30 minute expiration period.
func Default() Cache {
return cache.NewMemoryWithTTL(time.Minute * 30)
return NewTTL(time.Minute * 30)
}
// NewTTL returns an in-memory cache with the specified
@@ -31,9 +33,3 @@ func Default() Cache {
func NewTTL(t time.Duration) Cache {
return cache.NewMemoryWithTTL(t)
}
// NewTTL returns an in-memory cache with the specified
// ttl expiration period.
func NewLRU(size int) Cache {
return cache.NewLRU(size)
}