transactions

package
v0.13.7 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCleanupPeriod time.Duration = 30 * time.Minute

DefaultCleanupPeriod represents the default time duration after which cacheCleanService runs.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Cache represents a temporary store for response entries. Entries are evicted after a certain period, defined by cleanupPeriod. This works by keeping two maps of entries, and cycling the maps after the cleanupPeriod.

func New

func New() *Cache

New is a wrapper which calls NewWithCleanupPeriod with DefaultCleanupPeriod as argument.

func NewWithCleanupPeriod

func NewWithCleanupPeriod(cleanupPeriod time.Duration) *Cache

NewWithCleanupPeriod creates a new Cache object, starts cacheCleanService. Takes cleanupPeriod as argument. Returns a reference to newly created Cache.

func (*Cache) AddTransaction

func (t *Cache) AddTransaction(accessToken, txnID string, u *url.URL, res *util.JSONResponse)

AddTransaction adds an entry for the (accessToken, txnID, req.URL) tuple in Cache. Adds to the front txnMap.

func (*Cache) FetchTransaction

func (t *Cache) FetchTransaction(accessToken, txnID string, u *url.URL) (*util.JSONResponse, bool)

FetchTransaction looks up an entry for the (accessToken, txnID, req.URL) tuple in Cache. Looks in both the txnMaps. Returns (JSON response, true) if txnID is found, else the returned bool is false.

type CacheKey

type CacheKey struct {
	AccessToken string
	TxnID       string
	Endpoint    string
}

CacheKey is the type for the key in a transactions cache. This is needed because the spec requires transaction IDs to have a per-access token scope.

Jump to

Keyboard shortcuts

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