Documentation
¶
Index ¶
- type ExpirableItem
- type Item
- type ItemCache
- func (ic *ItemCache) Delete(key string)
- func (ic *ItemCache) Get(ctx context.Context, key string) (Item, func(), error)
- func (ic *ItemCache) GetOrCreate(ctx context.Context, key string, missFn ItemCreateFunc) (Item, func(), error)
- func (ic *ItemCache) Has(key string) bool
- func (ic *ItemCache) Keys() []string
- func (ic *ItemCache) Refresh(ctx context.Context, keys ...string) error
- func (ic *ItemCache) Set(item Item) error
- type ItemCreateFunc
- type RefreshableItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExpirableItem ¶
ExpirableItem is an Item that defines its own expiration criteria.
type ItemCache ¶
type ItemCache struct {
// contains filtered or unexported fields
}
ItemCache is a mechanism for caching Items to keys.
func NewItemCache ¶
NewItemCache creates a new ItemCache.
func (*ItemCache) Get ¶
Get returns an item from the cache if it exists, otherwise it returns an error. The item must be released by the caller when it is safe to be modified.
func (*ItemCache) GetOrCreate ¶
func (ic *ItemCache) GetOrCreate(ctx context.Context, key string, missFn ItemCreateFunc) (Item, func(), error)
GetOrCreate returns an item from the cache if it exists, otherwise it creates the item using the given function and caches it. The item must be released by the caller when it is safe to be modified.
type ItemCreateFunc ¶
Click to show internal directories.
Click to hide internal directories.