Documentation ¶
Index ¶
- Variables
- type Cache
- func (c Cache) Add(ctx context.Context, item *api.Item) (*api.Item, error)
- func (c Cache) DeleteAll(ctx context.Context, in *empty.Empty) (*api.Success, error)
- func (c Cache) DeleteKey(ctx context.Context, args *api.GetKey) (*api.Success, error)
- func (c Cache) Get(ctx context.Context, args *api.GetKey) (*api.Item, error)
- func (c Cache) GetAllItems(ctx context.Context, in *empty.Empty) (*api.AllItems, error)
- func (c Cache) GetByPrefix(ctx context.Context, args *api.GetKey) (*api.AllItems, error)
- type Item
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoKey for key not found ErrNoKey = errors.New("No key found") // ErrKeyExpired for keys expired ErrKeyExpired = errors.New("Key expired") )
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a struct in which the cache's methods synchronize access to this map, so it is not recommended to keep any references to the map around after creating a cache.
func NewCacheService ¶
NewCacheService is used to initialize a new cache. Return a new cache with a given default expiration duration and cleanup interval. If the expiration duration is less than one, the items in the cache never expire (by default), and must be deleted manually. If the cleanup interval is less than one, expired items are not deleted from the cache before calling c.deleteExpired().
func (Cache) DeleteKey ¶
DeleteKey deletes an item from the cache. Does nothing if the key is not in the cache.
func (Cache) GetAllItems ¶
GetAllItems method get all unexpired keys from the cache