12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- package cache
- import (
- cache "github.com/patrickmn/go-cache"
- "time"
- )
- var (
- std *cache.Cache
- )
- func init() {
- std = cache.New(time.Minute*10, time.Minute*30)
- }
- func Set(name string, value interface{}) {
- std.Set(name, value, 0)
- }
- func Get(name string) (interface{}, bool) {
- return std.Get(name)
- }
- func SetEx(name string, value interface{}, expired time.Duration) {
- std.Set(name, value, expired)
- }
- func Delete(name string) {
- std.Delete(name)
- }
- func Count() int {
- return std.ItemCount()
- }
- func Flush() {
- std.Flush()
- }
- func Save(filename string) (err error) {
- return std.SaveFile(filename)
- }
- func Load(filename string) (err error) {
- return std.LoadFile(filename)
- }
|