Update cache to satisfy Purge interface after context plumbing
This commit is contained in:
parent
43617619ad
commit
395befc062
|
@ -33,6 +33,8 @@ type TransactionalCache struct {
|
|||
Transactional
|
||||
}
|
||||
|
||||
var _ Purgable = &Cache{}
|
||||
|
||||
// NewCache returns a physical cache of the given size.
|
||||
// If no size is provided, the default size is used.
|
||||
func NewCache(b Backend, size int, coreExceptions []string, logger log.Logger) *Cache {
|
||||
|
@ -72,7 +74,7 @@ func NewTransactionalCache(b Backend, size int, coreExceptions []string, logger
|
|||
}
|
||||
|
||||
// Purge is used to clear the cache
|
||||
func (c *Cache) Purge() {
|
||||
func (c *Cache) Purge(ctx context.Context) {
|
||||
// Lock the world
|
||||
for _, lock := range c.locks {
|
||||
lock.Lock()
|
||||
|
|
|
@ -52,7 +52,7 @@ func TestCache_Purge(t *testing.T) {
|
|||
}
|
||||
|
||||
// Clear the cache
|
||||
cache.Purge()
|
||||
cache.Purge(context.Background())
|
||||
|
||||
// Read should fail
|
||||
out, err = cache.Get(context.Background(), "foo")
|
||||
|
|
Loading…
Reference in a new issue