Documentation
¶
Index ¶
- type Cache
- func (c *Cache) Add(obj interface{}) error
- func (c *Cache) Clear()
- func (c *Cache) Delete(obj interface{}) error
- func (c *Cache) Get(obj interface{}) (item interface{}, exists bool, err error)
- func (c *Cache) GetByKey(key string) (item interface{}, exists bool, err error)
- func (c *Cache) List() []interface{}
- func (c *Cache) ListKeys() []string
- func (c *Cache) Num() int
- func (c *Cache) Replace(list []interface{}) error
- func (c *Cache) Update(obj interface{}) error
- type DataNoExist
- type KeyError
- type ObjectKeyFunc
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache implements Store interface with a safe map
func (*Cache) ListKeys ¶
ListKeys returns a list of all the keys of the objects currently in the cache.
type DataNoExist ¶
type DataNoExist struct {
Obj interface{}
}
DataNoExist return when No data in Store
type KeyError ¶
type KeyError struct {
Obj interface{}
Err error
}
KeyError wrapper error return from ObjectKeyFunc
type ObjectKeyFunc ¶
ObjectKeyFunc define make object to a uniq key
type Store ¶
type Store interface {
Add(obj interface{}) error
Update(obj interface{}) error
Delete(obj interface{}) error
List() []interface{}
ListKeys() []string
Get(obj interface{}) (item interface{}, exists bool, err error)
GetByKey(key string) (item interface{}, exists bool, err error)
Num() int
Clear()
Replace([]interface{}) error
}
Store is storage interface
func NewCache ¶
func NewCache(kfunc ObjectKeyFunc) Store
NewCache create cache with designated ObjectKeyFunc
Click to show internal directories.
Click to hide internal directories.