Documentation ¶
Index ¶
Constants ¶
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 ¶
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 ¶
NewWithCleanupPeriod creates a new Cache object, starts cacheCleanService. Takes cleanupPeriod as argument. Returns a reference to newly created Cache.
func (*Cache) AddTransaction ¶
AddTransaction adds an entry for the (accessToken, txnID, req.URL) tuple in Cache. Adds to the front txnMap.
func (*Cache) FetchTransaction ¶
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.