feat: support ARC for DNS cache

This commit is contained in:
Larvan2
2023-12-02 17:07:36 +08:00
committed by wwqgtxx
parent bc74c943b8
commit 1a0932c210
24 changed files with 416 additions and 156 deletions

View File

@@ -3,12 +3,12 @@ package fakeip
import (
"net/netip"
"github.com/metacubex/mihomo/common/cache"
"github.com/metacubex/mihomo/common/lru"
)
type memoryStore struct {
cacheIP *cache.LruCache[string, netip.Addr]
cacheHost *cache.LruCache[netip.Addr, string]
cacheIP *lru.LruCache[string, netip.Addr]
cacheHost *lru.LruCache[netip.Addr, string]
}
// GetByHost implements store.GetByHost
@@ -73,7 +73,7 @@ func (m *memoryStore) FlushFakeIP() error {
func newMemoryStore(size int) *memoryStore {
return &memoryStore{
cacheIP: cache.New[string, netip.Addr](cache.WithSize[string, netip.Addr](size)),
cacheHost: cache.New[netip.Addr, string](cache.WithSize[netip.Addr, string](size)),
cacheIP: lru.New[string, netip.Addr](lru.WithSize[string, netip.Addr](size)),
cacheHost: lru.New[netip.Addr, string](lru.WithSize[netip.Addr, string](size)),
}
}