aurestcaching

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: MIT Imports: 7 Imported by: 4 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Instrument added in v0.4.0

func Instrument(
	client aurestclientapi.Client,
	cacheHitMetricsCallback aurestclientapi.MetricsCallbackFunction,
	cacheMissMetricsCallback aurestclientapi.MetricsCallbackFunction,
	cacheInvalidMetricsCallback aurestclientapi.MetricsCallbackFunction,
)

Instrument adds instrumentation to a http client.

Either of the callbacks may be nil.

func New

func New(
	wrapped aurestclientapi.Client,
	useCacheCondition aurestclientapi.CacheConditionCallback,
	storeResponseInCacheCondition aurestclientapi.CacheResponseConditionCallback,
	cacheKeyFunction aurestclientapi.CacheKeyFunction,
	retentionTime time.Duration,
	cacheSize int,
) aurestclientapi.Client

Types

type CacheEntry

type CacheEntry struct {
	Recorded           time.Time
	ResponseHeaderJson []byte
	ResponseBodyJson   []byte
	ResponseStatus     int
}

type CachingImpl

type CachingImpl struct {
	Wrapped aurestclientapi.Client

	UseCacheCondition             aurestclientapi.CacheConditionCallback
	StoreResponseInCacheCondition aurestclientapi.CacheResponseConditionCallback
	CacheKeyFunction              aurestclientapi.CacheKeyFunction
	RetentionTime                 time.Duration
	Cache                         *tinylru.LRU

	CacheHitMetricsCallback     aurestclientapi.MetricsCallbackFunction
	CacheMissMetricsCallback    aurestclientapi.MetricsCallbackFunction
	CacheInvalidMetricsCallback aurestclientapi.MetricsCallbackFunction

	// Now is exposed so tests can fixate the time by overwriting this field
	Now func() time.Time
}

func (*CachingImpl) Perform

func (c *CachingImpl) Perform(ctx context.Context, method string, requestUrl string, requestBody interface{}, response *aurestclientapi.ParsedResponse) error

Jump to

Keyboard shortcuts

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