Documentation ¶
Index ¶
- Constants
- func CalculateSize(val interface{}) int64
- func CovertSize(size string, defaultMemorySize int64) (int64, string)
- type Cache
- type CacheImpl
- func (c *CacheImpl) Del(key string) bool
- func (c *CacheImpl) Exists(key string) bool
- func (c *CacheImpl) Flush() bool
- func (c *CacheImpl) Get(key string) (interface{}, bool)
- func (c *CacheImpl) Keys() int64
- func (c *CacheImpl) Set(key string, val interface{}, expire ...time.Duration) bool
- func (c *CacheImpl) SetMaxMemory(size string) bool
- type MemoryCache
- func (m *MemoryCache) Del(key string) bool
- func (m *MemoryCache) Exists(key string) bool
- func (m *MemoryCache) Flush() bool
- func (m *MemoryCache) Get(key string) (interface{}, bool)
- func (m *MemoryCache) Keys() int64
- func (m *MemoryCache) Set(key string, val interface{}, expire time.Duration) bool
- func (m *MemoryCache) SetMaxMemory(size string) bool
Constants ¶
View Source
const ( B = 1 << (iota * 10) // 1 KB // 1024 MB // 1048576 GB // 1073741824 TB // 1099511627776 PB // 1125899906842624 )
Variables ¶
This section is empty.
Functions ¶
func CalculateSize ¶
func CalculateSize(val interface{}) int64
Types ¶
type Cache ¶
type Cache interface { SetMaxMemory(size string) bool Set(key string, val interface{}, expire time.Duration) bool Get(key string) (interface{}, bool) Del(key string) bool Exists(key string) bool Flush() bool Keys() int64 }
func NewMemCache ¶
func NewMemCache() Cache
type CacheImpl ¶
type CacheImpl struct {
// contains filtered or unexported fields
}
func (*CacheImpl) SetMaxMemory ¶
type MemoryCache ¶
type MemoryCache struct {
// contains filtered or unexported fields
}
func (*MemoryCache) Del ¶
func (m *MemoryCache) Del(key string) bool
func (*MemoryCache) Exists ¶
func (m *MemoryCache) Exists(key string) bool
func (*MemoryCache) Flush ¶
func (m *MemoryCache) Flush() bool
func (*MemoryCache) Get ¶
func (m *MemoryCache) Get(key string) (interface{}, bool)
func (*MemoryCache) Keys ¶
func (m *MemoryCache) Keys() int64
func (*MemoryCache) Set ¶
func (m *MemoryCache) Set(key string, val interface{}, expire time.Duration) bool
func (*MemoryCache) SetMaxMemory ¶
func (m *MemoryCache) SetMaxMemory(size string) bool
SetMaxMemory size: 1KB 100KB 1MB 100MB 1GB default 100MB
Click to show internal directories.
Click to hide internal directories.