var cacheTTL … var maxInFlight … var tokenLen … type requestCache … type request … type cacheEntry … func newRequestCache() *requestCache { … } // Insert the given request into the cache and returns the token used for fetching it out. func (c *requestCache) Insert(req request) (token string, err error) { … } // Consume the token (remove it from the cache) and return the cached request, if found. func (c *requestCache) Consume(token string) (req request, found bool) { … } // uniqueToken generates a random URL-safe token and ensures uniqueness. func (c *requestCache) uniqueToken() (string, error) { … } // Must be write-locked prior to calling. func (c *requestCache) gc() { … }