Documentation
¶
Index ¶
- Constants
- Variables
- func Append[T ScalarType](c *Cache, key string, val T) ([]T, error)
- func Dec[T NumType](c *Cache, key string, val T) (T, error)
- func Del(c *Cache, key string)
- func Exists(c *Cache, key string) bool
- func Get[T ValType](c *Cache, key string) (T, error)
- func GetTTL(c *Cache, key string) (time.Duration, error)
- func Inc[T NumType](c *Cache, key string, val T) (T, error)
- func Set[T ValType](c *Cache, key string, val T, ttl time.Duration)
- func TotalItems(c *Cache) int
- func TotalValidItems(c *Cache) int
- type Cache
- func (c *Cache) Close() error
- func (c *Cache) Del(key string)
- func (c *Cache) Exists(key string) bool
- func (c *Cache) Get(key string) (any, error)
- func (c *Cache) GetTTL(key string) (time.Duration, error)
- func (c *Cache) Set(key string, val any, ttl time.Duration)
- func (c *Cache) TotalItems() int
- func (c *Cache) TotalValidItems() int
- type FilePersister
- type Item
- type NumType
- type Persister
- type ScalarType
- type SliceType
- type ValType
Constants ¶
Variables ¶
View Source
var ( ErrNotExists = errors.New("key not exists") ErrInvalidType = errors.New("invalid type") )
Functions ¶
func TotalValidItems ¶
count only unexpired items, more expensive than TotalItems
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
func (*Cache) TotalItems ¶
func (*Cache) TotalValidItems ¶
type FilePersister ¶ added in v0.2.0
type FilePersister struct {
FilePath string
}
type Item ¶
type Item struct {
Object interface{}
ExpireMs int64 // expiration time in ms, never expire if equals to `kNoExpiration`
}
type ScalarType ¶
type ValType ¶
type ValType interface {
ScalarType | SliceType
}
Click to show internal directories.
Click to hide internal directories.