Documentation
¶
Index ¶
- Constants
- Variables
- type Cache
- func (c *Cache) Delete(ctx context.Context, host string) error
- func (c *Cache) Get(ctx context.Context, host string) (IPCache, error)
- func (c *Cache) GetDialContext(retryDialIfCacheFail ...bool) func(context.Context, string, string) (net.Conn, error)
- func (c *Cache) Lookup(ctx context.Context, host string) ([]net.IP, error)
- func (c *Cache) LookupWithCache(ctx context.Context, host string) ([]net.IP, error)
- func (c *Cache) Set(ctx context.Context, host string, ipCache IPCache) error
- type CacheOption
- func DialerOption(dialer *net.Dialer) CacheOption
- func NetworkOption(network int) CacheOption
- func OnStatsOption(onStats OnStats) CacheOption
- func PolicyOption(policy int) CacheOption
- func ResolverOption(resolver *net.Resolver) CacheOption
- func StaleOption(stale time.Duration) CacheOption
- func StorageOption(storage Storage) CacheOption
- func TimeoutOption(value time.Duration) CacheOption
- type IPCache
- type OnStats
- type Storage
Constants ¶
View Source
const ( PolicyFirst = iota PolicyRandom PolicyRoundRobin )
View Source
const ( NetworkIP = iota NetworkIPV4 NetworkIPV6 )
Variables ¶
View Source
var ErrNotFound = errors.New("Not Found")
Functions ¶
This section is empty.
Types ¶
type Cache ¶ added in v1.0.4
type Cache struct { Storage Storage TTL time.Duration Stale time.Duration OnStats OnStats Dialer *net.Dialer Resolver *net.Resolver Policy int Network int Timeout time.Duration // contains filtered or unexported fields }
Cache dns cache
func New ¶ added in v1.0.4
func New(ttl time.Duration, opts ...CacheOption) *Cache
New create a dns cache instance
func (*Cache) GetDialContext ¶ added in v1.0.4
func (c *Cache) GetDialContext(retryDialIfCacheFail ...bool) func(context.Context, string, string) (net.Conn, error)
GetDialContext get dial context function with cache
func (*Cache) LookupWithCache ¶ added in v1.0.4
LookupWithCache lookup with cache
type CacheOption ¶ added in v1.0.4
type CacheOption func(*Cache)
func DialerOption ¶ added in v1.0.4
func DialerOption(dialer *net.Dialer) CacheOption
DialerOption sets dialer
func NetworkOption ¶ added in v1.0.4
func NetworkOption(network int) CacheOption
NetworkOption set network option
func OnStatsOption ¶ added in v1.0.4
func OnStatsOption(onStats OnStats) CacheOption
OnStatsOption sets on stats function
func PolicyOption ¶ added in v1.0.4
func PolicyOption(policy int) CacheOption
PolicyOption sets policy
func ResolverOption ¶ added in v1.0.4
func ResolverOption(resolver *net.Resolver) CacheOption
ResolverOption sets resolver
func StaleOption ¶ added in v1.0.4
func StaleOption(stale time.Duration) CacheOption
StaleOption sets stale
func StorageOption ¶ added in v1.0.4
func StorageOption(storage Storage) CacheOption
StorageOption sets storage
func TimeoutOption ¶ added in v1.0.4
func TimeoutOption(value time.Duration) CacheOption
TimeoutOption set timeout option
Click to show internal directories.
Click to hide internal directories.