mirror of
https://github.com/hashicorp/vault.git
synced 2026-05-05 12:26:34 +02:00
Update cache to satisfy Purge interface after context plumbing
This commit is contained in:
parent
1e78dfb8ac
commit
c6ff8d35f3
@ -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…
x
Reference in New Issue
Block a user