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
|
Transactional
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ Purgable = &Cache{}
|
||||||
|
|
||||||
// NewCache returns a physical cache of the given size.
|
// NewCache returns a physical cache of the given size.
|
||||||
// If no size is provided, the default size is used.
|
// If no size is provided, the default size is used.
|
||||||
func NewCache(b Backend, size int, coreExceptions []string, logger log.Logger) *Cache {
|
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
|
// Purge is used to clear the cache
|
||||||
func (c *Cache) Purge() {
|
func (c *Cache) Purge(ctx context.Context) {
|
||||||
// Lock the world
|
// Lock the world
|
||||||
for _, lock := range c.locks {
|
for _, lock := range c.locks {
|
||||||
lock.Lock()
|
lock.Lock()
|
||||||
|
|
|
@ -52,7 +52,7 @@ func TestCache_Purge(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear the cache
|
// Clear the cache
|
||||||
cache.Purge()
|
cache.Purge(context.Background())
|
||||||
|
|
||||||
// Read should fail
|
// Read should fail
|
||||||
out, err = cache.Get(context.Background(), "foo")
|
out, err = cache.Get(context.Background(), "foo")
|
||||||
|
|
Loading…
Reference in a new issue