Documentation ¶
Index ¶
- Variables
- type CacheFile
- func (c *CacheFile) Close() error
- func (c *CacheFile) DelFakeipPair(ip, host []byte) error
- func (c *CacheFile) GetFakeip(key []byte) []byte
- func (c *CacheFile) PutFakeip(key, value []byte) error
- func (c *CacheFile) SelectedMap() map[string]string
- func (c *CacheFile) SetSelected(group, selected string)
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 ¶
CacheFile store and update the cache file
func (*CacheFile) DelFakeipPair ¶
func (*CacheFile) SelectedMap ¶
func (*CacheFile) SetSelected ¶
Click to show internal directories.
Click to hide internal directories.