Documentation
¶
Index ¶
- Constants
- Variables
- func FilenameExists(filename string) bool
- func GetCurrentDir() (string, error)
- func IsNotFoundErr(err error) bool
- type CacheStore
- type Cacher
- type Disk
- type IValue
- type LRUCache
- type LimitMemoryCache
- func (m *LimitMemoryCache) Close() error
- func (m *LimitMemoryCache) Del(key string) error
- func (m *LimitMemoryCache) Get(key string) (interface{}, error)
- func (m *LimitMemoryCache) Set(key string, value interface{}) error
- func (m *LimitMemoryCache) SetWithTTL(key string, value interface{}, ttl time.Duration) error
- type MemoryStore
Constants ¶
View Source
const ( GCInterval = 60 * time.Minute CacheGcMaxRemoved = 30 )
Variables ¶
View Source
var ( ErrNotFound = errors.New("bkit/caches: not found") ErrSizeOverCapacity = errors.New("bkit/caches: memory size over set the capacity") )
Functions ¶
func FilenameExists ¶
func IsNotFoundErr ¶
Types ¶
type CacheStore ¶
type Disk ¶
type Disk struct {
// contains filtered or unexported fields
}
func (*Disk) WriteToFile ¶
WriteToFile if file exists, just del
type IValue ¶
type IValue struct { Value interface{} `json:"v"` ExpiredTime time.Time `json:"e"` Size int32 `json:"s"` }
func (*IValue) SetExpiredTime ¶
type LRUCache ¶
type LRUCache struct { MaxElement int // contains filtered or unexported fields }
func NewLRUCache ¶
func NewLRUCache(store CacheStore, maxElement int) *LRUCache
NewLRUCache lru cache maxElement min set 100
type LimitMemoryCache ¶
type LimitMemoryCache struct {
// contains filtered or unexported fields
}
LimitMemoryCache limit Memory use, implement cacher, suitable high performance, storage small.
func NewLimitMemoryCache ¶
func NewLimitMemoryCache(size int32, filename ...string) *LimitMemoryCache
NewMemCache size=-1 not limit, 1<<20(1MB) filename if pass in, Close will save to file
func (*LimitMemoryCache) Close ¶
func (m *LimitMemoryCache) Close() error
Close if enable save to file, save()
func (*LimitMemoryCache) Del ¶
func (m *LimitMemoryCache) Del(key string) error
func (*LimitMemoryCache) Get ¶
func (m *LimitMemoryCache) Get(key string) (interface{}, error)
func (*LimitMemoryCache) Set ¶
func (m *LimitMemoryCache) Set(key string, value interface{}) error
func (*LimitMemoryCache) SetWithTTL ¶
func (m *LimitMemoryCache) SetWithTTL(key string, value interface{}, ttl time.Duration) error
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore represents in-memory store
func NewMemoryStore ¶
func NewMemoryStore() *MemoryStore
NewMemoryStore creates a new store in memory
func (*MemoryStore) Get ¶
func (s *MemoryStore) Get(key string) (interface{}, error)
Get gets object from store
func (*MemoryStore) Range ¶
func (s *MemoryStore) Range(f func(key, value interface{}) bool)
func (*MemoryStore) Set ¶
func (s *MemoryStore) Set(key string, value interface{}) error
Set sets object into store
Click to show internal directories.
Click to hide internal directories.