Documentation ¶
Index ¶
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
}
func New ¶
New creates a cache where items are evicted after being present for `expirationTime`. `name` is used to name the gauge used for metrics reporting.
func (*Cache) GetOrRetrieve ¶
func (c *Cache) GetOrRetrieve(ctx context.Context, key string, retriever Retriever) (interface{}, error)
GetOrRetrieve will return the cached value and if it isn't present will call `Retriever`. It is guaranteed there will only on one concurrent call to `Retriever` for each key, other accesses to the key will be blocked until `Retriever.Call` returns. If `Retriever.Call` fails the error will not be cached and subsequent calls will call the `Retriever` again.
Click to show internal directories.
Click to hide internal directories.