Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface {
// Get retrieves a value at `key` using command `cmd`. It returns the value, the remaining ttl of the key,
// its delta, and any error.
Get(ctx context.Context, cmd, key string) (interface{}, float64, float64, error)
// Put puts the values at `args` at `key` using command `cmd`. It also sets its ttl and stores the delta.
Put(ctx context.Context, cmd, key string, ttl, delta time.Duration, args ...interface{}) error
}
Cache abstracts away cache operations. You can use any kind of cache or caching library to implement it.
type Fetcher ¶
type Fetcher interface {
// Get returns a value at `key` from the cache. It wraps it in a Retrieval and returns any error encountered.
Get(ctx context.Context, cache Cache, cmd, key string) (*Retrieval, error)
// Put delegates putting an object to the cache to the Cache implementation.
Put(ctx context.Context, cache Cache, cmd, key string, ttl, delta time.Duration, args ...interface{}) error
}
Fetcher describes an X-Fetch client.
func NewFetcher ¶
NewFetcher takes the ttl of a cache key and its beta value and returns a Fetcher, using rand.Float64 as a randomizer
func NewFetcherWithRandomizer ¶
func NewFetcherWithRandomizer(beta float64, randomizer Randomizer) Fetcher
NewFetcher takes the ttl of a cache key, its beta value and a Randomizer and returns a Fetcher
Click to show internal directories.
Click to hide internal directories.