cache

package
v2.10.0-beta4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Fetcher
	services.Service
}

Cache is scoped to one particular mercury server Use CacheSet to hold lookups for multiple servers

func NewCache

func NewCache(lggr logger.Logger, client Client, cfg Config) Cache

type CacheSet

type CacheSet interface {
	services.Service
	Get(ctx context.Context, client Client) (Fetcher, error)
}

CacheSet holds a set of mercury caches keyed by server URL

func NewCacheSet

func NewCacheSet(lggr logger.Logger, cfg Config) CacheSet

type Client

type Client interface {
	Fetcher
	ServerURL() string
	RawClient() pb.MercuryClient
}

type Config

type Config struct {
	// LatestReportTTL controls how "stale" we will allow a price to be e.g. if
	// set to 1s, a new price will always be fetched if the last result was
	// from more than 1 second ago.
	//
	// Another way of looking at it is such: the cache will _never_ return a
	// price that was queried from before now-LatestReportTTL.
	//
	// Setting to zero disables caching entirely.
	LatestReportTTL time.Duration
	// MaxStaleAge is that maximum amount of time that a value can be stale
	// before it is deleted from the cache (a form of garbage collection).
	//
	// This should generally be set to something much larger than
	// LatestReportTTL. Setting to zero disables garbage collection.
	MaxStaleAge time.Duration
	// LatestReportDeadline controls how long to wait for a response before
	// retrying. Setting this to zero will wait indefinitely.
	LatestReportDeadline time.Duration
}

type Fetcher

type Fetcher interface {
	LatestReport(ctx context.Context, req *pb.LatestReportRequest) (resp *pb.LatestReportResponse, err error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL