Documentation ¶
Index ¶
- Constants
- func Add(k string, v interface{}, second int) (err error)
- func Get(key string) (interface{}, bool)
- func Init()
- func Set(k string, v interface{}, second int)
- type Cache
- func (c *Cache) Add(k string, v interface{}, d time.Duration) error
- func (c *Cache) Count() int
- func (c *Cache) Delete(k string)
- func (c *Cache) DeleteExpired()
- func (c *Cache) Flush()
- func (c *Cache) Get(k string) (interface{}, bool)
- func (c *Cache) Load(r io.Reader) error
- func (c *Cache) LoadFile(file string) error
- func (c *Cache) Replace(k string, v interface{}, d time.Duration) error
- func (c *Cache) Save(w io.Writer) (err error)
- func (c *Cache) SaveToFile(file string) error
- func (c *Cache) Set(k string, v interface{}, d time.Duration)
- func (c *Cache) StopGc()
- type Config
- type Item
Constants ¶
View Source
const ( // 没有过期时间标志 -不过期 NoExpiration time.Duration = -1 // 默认的过期时间 DefaultExpiration time.Duration = 0 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache struct { Items map[string]Item // 缓存数据项存储在 map 中 File string // contains filtered or unexported fields }
var Obj Cache
type Config ¶
type Config struct { //是否启用 Enable bool `toml:"enable"` //缓存默认过期时间(秒) ,传递-1时取此值 Expiration int32 `toml:"expiration"` //是否实时输出到缓存文件 RealtimeSave bool `toml:"realtime_save"` //缓存文件保存周期(秒),realtime_save=false 才会生效 SavefileCycle int32 `toml:"savefile_cycle"` //缓存文件保存路径 SavefilePath string `toml:"savefile_path"` }
Click to show internal directories.
Click to hide internal directories.