2020-01-25 17:43:02 +00:00
|
|
|
package cache
|
2013-07-23 11:10:38 +00:00
|
|
|
|
2013-07-24 10:29:38 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
2015-02-10 09:00:59 +00:00
|
|
|
|
2019-09-26 04:43:17 +00:00
|
|
|
"github.com/miekg/dns"
|
2013-07-24 10:29:38 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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 {
|
2016-02-13 09:55:19 +00:00
|
|
|
err error
|
2013-07-24 10:29:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (e SerializerError) Error() string {
|
2016-02-13 09:55:19 +00:00
|
|
|
return fmt.Sprintf("Serializer error: got %v", e.err)
|
2013-07-24 10:29:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Cache interface {
|
2013-07-24 16:09:07 +00:00
|
|
|
Get(key string) (Msg *dns.Msg, err error)
|
|
|
|
Set(key string, Msg *dns.Msg) error
|
2013-07-24 14:47:39 +00:00
|
|
|
Exists(key string) bool
|
2016-02-12 16:08:48 +00:00
|
|
|
Remove(key string) error
|
|
|
|
Full() bool
|
2020-01-25 17:43:02 +00:00
|
|
|
Purge() error
|
2018-07-01 15:49:24 +00:00
|
|
|
}
|