cachefile

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: GPL-3.0 Imports: 7 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cache = sync.OnceValue(func() *CacheFile {
	options := bbolt.Options{Timeout: time.Second}
	db, err := bbolt.Open(C.Path.Cache(), fileMode, &options)
	switch err {
	case bbolt.ErrInvalid, bbolt.ErrChecksum, bbolt.ErrVersionMismatch:
		if err = os.Remove(C.Path.Cache()); err != nil {
			log.Warnln("[CacheFile] remove invalid cache file error: %s", err.Error())
			break
		}
		log.Infoln("[CacheFile] remove invalid cache file and create new one")
		db, err = bbolt.Open(C.Path.Cache(), fileMode, &options)
	}
	if err != nil {
		log.Warnln("[CacheFile] can't open cache file: %s", err.Error())
	}

	return &CacheFile{
		DB: db,
	}
})

Cache return singleton of CacheFile

Functions

This section is empty.

Types

type CacheFile

type CacheFile struct {
	DB *bbolt.DB
}

CacheFile store and update the cache file

func (*CacheFile) Close added in v1.8.0

func (c *CacheFile) Close() error

func (*CacheFile) DelFakeipPair added in v1.9.0

func (c *CacheFile) DelFakeipPair(ip, host []byte) error

func (*CacheFile) GetFakeip added in v1.8.0

func (c *CacheFile) GetFakeip(key []byte) []byte

func (*CacheFile) PutFakeip added in v1.8.0

func (c *CacheFile) PutFakeip(key, value []byte) error

func (*CacheFile) SelectedMap

func (c *CacheFile) SelectedMap() map[string]string

func (*CacheFile) SetSelected

func (c *CacheFile) SetSelected(group, selected string)

Jump to

Keyboard shortcuts

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