Documentation
¶
Index ¶
- Variables
- type CacheFile
- func (c *CacheFile) Close() error
- func (c *CacheFile) DelFakeipPair(ip, host []byte) error
- func (c *CacheFile) FlushFakeIP() error
- func (c *CacheFile) GetFakeip(key []byte) []byte
- func (c *CacheFile) GetSubscription(key string) string
- func (c *CacheFile) PutFakeip(key, value []byte) error
- func (c *CacheFile) SelectedMap() map[string]string
- func (c *CacheFile) SetBucketFakeipKey(key string)
- func (c *CacheFile) SetSelected(group, selected string)
- func (c *CacheFile) SetSubscription(key, value 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 errors.ErrInvalid, errors.ErrChecksum, errors.ErrVersionMismatch: if err = os.Remove(C.Path.Cache()); err != nil { log.Warn().Err(err).Msg("[CacheFile] remove invalid cache file failed") break } log.Info().Msg("[CacheFile] remove invalid cache file and create new one") db, err = bbolt.Open(C.Path.Cache(), fileMode, &options) } if err != nil { log.Warn().Err(err).Msg("[CacheFile] open cache file failed") } return &CacheFile{ DB: db, bucketFakeipKey: []byte("fakeip"), } })
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) FlushFakeIP ¶
func (*CacheFile) GetSubscription ¶
func (*CacheFile) SelectedMap ¶
func (*CacheFile) SetBucketFakeipKey ¶ added in v1.69.0
func (*CacheFile) SetSelected ¶
func (*CacheFile) SetSubscription ¶
Click to show internal directories.
Click to hide internal directories.