Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // DefaultCache is the default cache. DefaultCache Cache = NewCache() // DefaultExpiration is the default duration for items stored in the cache to expire. DefaultExpiration time.Duration = 0 ErrItemExpired = errors.New("item has expired") ErrKeyNotFound = errors.New("key not found in cache") )
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface {
Get(ctx context.Context, key string) (interface{}, time.Time, error)
Set(ctx context.Context, key string, value interface{}, d time.Duration) error
Del(ctx context.Context, key string) error
}
Cache is the interface that wraps the cache.
type Item ¶
type Item struct {
Value interface{}
Expiration int64
}
Item represents an item stored in the cache.
type Option ¶
type Option func(*Options)
func WithAddress ¶
WithAddress sets the cache service address or connection information.
func WithExpiration ¶
Click to show internal directories.
Click to hide internal directories.