Documentation ¶
Index ¶
- Variables
- func FileGetContents(filename string) (data []byte, e error)
- func FilePutContents(filename string, content []byte) error
- func GetBool(v interface{}) bool
- func GetFloat64(v interface{}) float64
- func GetInt(v interface{}) int
- func GetInt64(v interface{}) int64
- func GetString(v interface{}) string
- func GobDecode(data []byte, to *FileItem) error
- func GobEncode(data interface{}) ([]byte, error)
- func Register(name string, adapter Instance)
- type Cache
- type FileCache
- func (fc *FileCache) ClearAll() error
- func (fc *FileCache) Decr(key string) error
- func (fc *FileCache) Delete(key string) error
- func (fc *FileCache) Get(key string) interface{}
- func (fc *FileCache) GetMulti(keys []string) []interface{}
- func (fc *FileCache) Incr(key string) error
- func (fc *FileCache) IsExist(key string) bool
- func (fc *FileCache) Put(key string, val interface{}, timeout time.Duration) error
- func (fc *FileCache) StartAndGC(config string) error
- type FileItem
- type Instance
- type MemoryCache
- func (bc *MemoryCache) ClearAll() error
- func (bc *MemoryCache) Decr(key string) error
- func (bc *MemoryCache) Delete(name string) error
- func (bc *MemoryCache) Get(name string) interface{}
- func (bc *MemoryCache) GetMulti(names []string) []interface{}
- func (bc *MemoryCache) Incr(key string) error
- func (bc *MemoryCache) IsExist(name string) bool
- func (bc *MemoryCache) Put(name string, value interface{}, ttr time.Duration) error
- func (bc *MemoryCache) StartAndGC(config string) error
- type MemoryItem
- type RedisCache
- func (rc *RedisCache) ClearAll() error
- func (rc *RedisCache) Decr(key string) error
- func (rc *RedisCache) Delete(key string) error
- func (rc *RedisCache) Get(key string) interface{}
- func (rc *RedisCache) GetMulti(keys []string) []interface{}
- func (rc *RedisCache) Incr(key string) error
- func (rc *RedisCache) IsExist(key string) bool
- func (rc *RedisCache) Put(key string, val interface{}, timeout time.Duration) error
- func (rc *RedisCache) StartAndGC(config string) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( FileCachePath = "runtime/cache" // 缓存目录 FileCacheFileSuffix = ".gob" // 缓存文件后缀 FileCacheDirectoryLevel = 1 // 缓存目录层级 FileCacheExpire time.Duration // 缓存过期时间 )
View Source
var ( // 默认回收过期缓存时间,默认一分钟 DefaultEvery int = 60 )
View Source
var (
DefaultKey = "redisCache"
)
Functions ¶
Types ¶
type Cache ¶
type Cache interface { // 获取缓存 Get(key string) interface{} // 获取多个缓存 GetMulti(keys []string) []interface{} // 设置缓存和有效期 Put(key string, val interface{}, timeout time.Duration) error // 删除一个缓存 Delete(key string) error // 自增一个值 Incr(key string) error // 自减一个值 Decr(key string) error // 检查key是否存在 IsExist(key string) bool // 清除所有缓存 ClearAll() error // 启动并回收 StartAndGC(config string) error }
缓存接口
func NewRedisCache ¶
func NewRedisCache() Cache
type FileCache ¶
type FileCache struct { CachePath string // 缓存目录 FileSuffix string // 缓存文件后缀 DirectoryLevel int // 缓存目录层级 CacheExpire int // 缓存过期时间 }
type MemoryCache ¶
缓冲驱动结构
func (*MemoryCache) Decr ¶
func (bc *MemoryCache) Decr(key string) error
func (*MemoryCache) Incr ¶
func (bc *MemoryCache) Incr(key string) error
自增 支持int int32 int66 uint uint32 unit64
type RedisCache ¶
type RedisCache struct {
// contains filtered or unexported fields
}
func (*RedisCache) ClearAll ¶
func (rc *RedisCache) ClearAll() error
func (*RedisCache) Decr ¶
func (rc *RedisCache) Decr(key string) error
func (*RedisCache) Delete ¶
func (rc *RedisCache) Delete(key string) error
func (*RedisCache) Get ¶
func (rc *RedisCache) Get(key string) interface{}
func (*RedisCache) GetMulti ¶
func (rc *RedisCache) GetMulti(keys []string) []interface{}
func (*RedisCache) Incr ¶
func (rc *RedisCache) Incr(key string) error
func (*RedisCache) IsExist ¶
func (rc *RedisCache) IsExist(key string) bool
func (*RedisCache) Put ¶
func (rc *RedisCache) Put(key string, val interface{}, timeout time.Duration) error
func (*RedisCache) StartAndGC ¶
func (rc *RedisCache) StartAndGC(config string) error
Click to show internal directories.
Click to hide internal directories.