Documentation ¶
Index ¶
- type Cache
- func (c *Cache) Delete(key string) bool
- func (c *Cache) Get(key string) (dns.Msg, bool)
- func (c *Cache) GetEntry(key string) (Entry, bool)
- func (c *Cache) Insert(key string, value dns.Msg) bool
- func (c *Cache) InsertFromParams(key string, ip string, recordType uint16, ttl int) bool
- func (c *Cache) MarshalJSON() ([]byte, error)
- type Entry
- type StringEntry
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
Cache object
func NewCache ¶
NewCache returns a new cache instance
Example ¶
package main import ( "github.com/dvlahovski/go-dnscached/cache" "github.com/dvlahovski/go-dnscached/config" ) func main() { config, err := config.Load("../config/config.json") if err != nil { return } _ = cache.NewCache(*config) }
Output:
func (*Cache) Insert ¶
Insert a DNS msg in the cache
Example ¶
package main import ( "fmt" "github.com/dvlahovski/go-dnscached/cache" "github.com/dvlahovski/go-dnscached/config" "github.com/miekg/dns" ) func main() { config, err := config.Load("../config/config.json") if err != nil { return } cache := cache.NewCache(*config) ok := cache.Insert("google.bg", dns.Msg{}) if !ok { fmt.Printf("insertion failed") } }
Output:
func (*Cache) InsertFromParams ¶
InsertFromParams - insert and entry from separate params
Example ¶
package main import ( "fmt" "github.com/dvlahovski/go-dnscached/cache" "github.com/dvlahovski/go-dnscached/config" "github.com/miekg/dns" ) func main() { config, err := config.Load("../config/config.json") if err != nil { return } cache := cache.NewCache(*config) ok := cache.InsertFromParams("google.bg", "1.2.3.4", dns.TypeA, 120) fmt.Printf("%t\n", ok) }
Output: true
func (*Cache) MarshalJSON ¶
MarshalJSON returns a json representation of the cache's contents
type Entry ¶
Entry is the cache's internal entry representation
func (Entry) MarshalJSON ¶
func (Entry) ToStringEntry ¶
func (e Entry) ToStringEntry() StringEntry
Click to show internal directories.
Click to hide internal directories.