godns/cache/cache.go
2020-01-25 12:43:02 -05:00

47 lines
708 B
Go

package cache
import (
"fmt"
"github.com/miekg/dns"
)
type KeyNotFound struct {
key string
}
func (e KeyNotFound) Error() string {
return e.key + " " + "not found"
}
type KeyExpired struct {
Key string
}
func (e KeyExpired) Error() string {
return e.Key + " " + "expired"
}
type CacheIsFull struct {
}
func (e CacheIsFull) Error() string {
return "Cache is Full"
}
type SerializerError struct {
err error
}
func (e SerializerError) Error() string {
return fmt.Sprintf("Serializer error: got %v", e.err)
}
type Cache interface {
Get(key string) (Msg *dns.Msg, err error)
Set(key string, Msg *dns.Msg) error
Exists(key string) bool
Remove(key string) error
Full() bool
Purge() error
}