func (c *Cache) Purge(ctx context.Context) {
	for _, lock := range c.locks {
		lock.Lock()
		defer lock.Unlock()
	}
	c.lru.Purge()
}
Purge is used to clear the cache
package physical
import (
	"context"
	"sync/atomic"
	log "github.com/hashicorp/go-hclog"
	"github.com/hashicorp/golang-lru"
	"github.com/hashicorp/vault/helper/locksutil"
	"github.com/hashicorp/vault/helper/pathmanager"
)
const (
	DefaultCacheSize = 128 * 1024
)
var cacheExceptionsPaths = []string{
	"wal/logs/",
	"index/pages/",
	"index-dr/pages/",
	"sys/expire/",
}
type Cache struct {
	backend         Backend
	lru             *lru.TwoQueueCache
	locks           []*locksutil.LockEntry
	logger          log.Logger
	enabled         *uint32
	cacheExceptions *pathmanager.PathManager
}
type TransactionalCache struct {
	*Cache
	Transactional
}
var _ ToggleablePurgemonster = (*Cache)(nil)
var _ ToggleablePurgemonster = (*TransactionalCache)(nil)
var _ Backend = (*Cache)(nil)
var _ Transactional = (*TransactionalCache)(nil)
func NewCache(b Backend, size int, logger log.Logger) *Cache {
	if logger.IsDebug() {
		logger.Debug("creating LRU cache", "size", size)
	}
	if size <= 0 {
		size = DefaultCacheSize
	}
	pm := pathmanager.New()
	pm.AddPaths(cacheExceptionsPaths)
	cache, _ := lru.New2Q(size)
	c := &Cache{
		backend: b,
		lru:     cache,
		locks:   locksutil.CreateLocks(),
		logger:  logger,
		enabled:         new(uint32),
		cacheExceptions: pm,
	}
	return c
}
func NewTransactionalCache(b Backend, size int, logger log.Logger) *TransactionalCache {
	c := &TransactionalCache{
		Cache:         NewCache(b, size, logger),
		Transactional: b.(Transactional),
	}
	return c
}
func (c *Cache) shouldCache(key string) bool {
	if atomic.LoadUint32(c.enabled) == 0 {
		return false
	}
	return !c.cacheExceptions.HasPath(key)
}
func (c *Cache) SetEnabled(enabled bool) {
	if enabled {
		atomic.StoreUint32(c.enabled, 1)
		return
	}
	atomic.StoreUint32(c.enabled, 0)
}