mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-02-03 22:18:39 +00:00
all: add flush cache domains config
This commit is contained in:
committed by
Cuong Manh Le
parent
34ebe9b054
commit
b50cccac85
@@ -12,6 +12,7 @@ import (
|
||||
type Cacher interface {
|
||||
Get(Key) *Value
|
||||
Add(Key, *Value)
|
||||
Purge()
|
||||
}
|
||||
|
||||
// Key is the caching key for DNS message.
|
||||
@@ -34,15 +35,22 @@ type LRUCache struct {
|
||||
cacher *lru.ARCCache[Key, *Value]
|
||||
}
|
||||
|
||||
// Get looks up key's value from cache.
|
||||
func (l *LRUCache) Get(key Key) *Value {
|
||||
v, _ := l.cacher.Get(key)
|
||||
return v
|
||||
}
|
||||
|
||||
// Add adds a value to cache.
|
||||
func (l *LRUCache) Add(key Key, value *Value) {
|
||||
l.cacher.Add(key, value)
|
||||
}
|
||||
|
||||
// Purge clears the cache.
|
||||
func (l *LRUCache) Purge() {
|
||||
l.cacher.Purge()
|
||||
}
|
||||
|
||||
// NewLRUCache creates a new LRUCache instance with given size.
|
||||
func NewLRUCache(size int) (*LRUCache, error) {
|
||||
cacher, err := lru.NewARC[Key, *Value](size)
|
||||
|
||||
Reference in New Issue
Block a user