cache

package
v1.6.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2021 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeferCacheStore added in v1.5.2

type DeferCacheStore struct {
	// contains filtered or unexported fields
}

func NewDeferStore added in v1.5.2

func NewDeferStore(key string, backend DnsCache) *DeferCacheStore

func (*DeferCacheStore) Exec added in v1.5.2

func (d *DeferCacheStore) Exec(ctx context.Context, qCtx *handler.Context) (err error)

Exec caches the response. It never returns an err, because a cache fault should not terminate the query process.

type DnsCache

type DnsCache interface {
	// Get retrieves v from DnsCache. The returned v is a deepcopy of the original msg
	// that stored in the cache. The TTLs of v has already been modified properly.
	// The only thing that call should modify is msg's id.
	Get(ctx context.Context, key string) (v *dns.Msg, err error)
	// Store stores the v into DnsCache. It stores the deepcopy of v.
	Store(ctx context.Context, key string, v *dns.Msg, ttl time.Duration) (err error)

	// Closer closes the cache backend.
	io.Closer
}

DnsCache represents a DNS cache backend.

type MemCache

type MemCache struct {
	// contains filtered or unexported fields
}

MemCache is a simple cache that stores msgs in memory.

func NewMemCache

func NewMemCache(shardNum, maxSizePerShard int, cleanerInterval time.Duration) *MemCache

NewMemCache returns a MemCache. If cleanerInterval <= 0, MemCache cleaner is disabled. If shardNum or maxSizePerShard <=0, NewMemCache will panic.

func (*MemCache) Close

func (c *MemCache) Close() error

Close closes the cleaner

func (*MemCache) Get

func (c *MemCache) Get(_ context.Context, key string) (v *dns.Msg, err error)

func (*MemCache) Store

func (c *MemCache) Store(_ context.Context, key string, v *dns.Msg, ttl time.Duration) (err error)

type RedisCache added in v1.5.2

type RedisCache struct {
	// contains filtered or unexported fields
}

func NewRedisCache

func NewRedisCache(url string) (*RedisCache, error)

func (*RedisCache) Close added in v1.5.2

func (r *RedisCache) Close() error

Close closes the redis client.

func (*RedisCache) Get added in v1.5.2

func (r *RedisCache) Get(ctx context.Context, key string) (v *dns.Msg, err error)

func (*RedisCache) Store added in v1.5.2

func (r *RedisCache) Store(ctx context.Context, key string, v *dns.Msg, ttl time.Duration) (err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL