// RequestCache specifies if this request should use the request cache
// or not, assuming that it can. By default, will default to the index
// level setting if request cache is enabled or not.
966459
func (r *SearchRequest) RequestCache(requestCache bool) *SearchRequest {
	r.requestCache = &requestCache
	return r
}
717905
func (h *hawkularSink) cache(md *metrics.MetricDefinition) {
	h.pushToCache(md.ID, hashDefinition(md))
}
1195755
func (client *Client) EnableCaching(config CacheConfig) error {
	cache, err := newHTTPCacheClient(client.debug, config)
	if err != nil {
		return err
	}

	client.Transport = cache
	return nil
}
423759
func (c *requestCache) gc() {
	now := c.clock.Now()
	for c.ll.Len() > 0 {
		oldest := c.ll.Back()
		entry := oldest.Value.(*cacheEntry)
		if !now.After(entry.expireTime) {
			return
		}

		// Oldest value is expired; remove it.
		c.ll.Remove(oldest)
		delete(c.tokens, entry.token)
	}
}
761104
func (o *ListOptions) UseCache(key string, ttl time.Duration) {
	o.cacheKey, o.cacheTTL = key, ttl
}
863345
func RequestCache(c context.Context) *lru.Cache {
	rc, _ := c.Value(&requestCacheKey).(*lru.Cache)
	if rc == nil {
		panic("server/caching: no request cache installed in Context")
	}
	return rc
}
225020
func (engine *Engine) NoCache() *Session {
	session := engine.NewSession()
	session.IsAutoClose = true
	return session.NoCache()
}
782904
func SetCacheHandler(w http.ResponseWriter, r *http.Request) {
	n, _ := strconv.Atoi(mux.Vars(r)["n"]) // shouldn't fail due to route pattern
	w.Header().Set("Cache-Control", fmt.Sprintf("public, max-age=%d", n))
	GetHandler(w, r)
}
311274
func (s *CreateProjectInput) SetCache(v *ProjectCache) *CreateProjectInput {
	s.Cache = v
	return s
}
1231243
func (s *UpdateByQueryService) RequestCache(requestCache bool) *UpdateByQueryService {
	s.requestCache = &requestCache
	return s
}
1363370
func (c *requestCache) Consume(token string) (req request, found bool) {
	c.lock.Lock()
	defer c.lock.Unlock()
	ele, ok := c.tokens[token]
	if !ok {
		return nil, false
	}
	c.ll.Remove(ele)
	delete(c.tokens, token)

	entry := ele.Value.(*cacheEntry)
	if c.clock.Now().After(entry.expireTime) {
		// Entry already expired.
		return nil, false
	}
	return entry.req, true
}
1086641
func shouldCache(attr authorizer.Attributes) bool {
	controlledAttrSize := int64(len(attr.GetNamespace())) +
		int64(len(attr.GetVerb())) +
		int64(len(attr.GetAPIGroup())) +
		int64(len(attr.GetAPIVersion())) +
		int64(len(attr.GetResource())) +
		int64(len(attr.GetSubresource())) +
		int64(len(attr.GetName())) +
		int64(len(attr.GetPath()))
	return controlledAttrSize < maxControlledAttrCacheSize
}
1340479
func (j *jws) cache() (err error) {
	if !j.clean {
		j.plcache, err = j.payload.Base64()
		j.clean = err == nil
	}
	return err
}
1002672
func (c *CacheStorage) RequestCachedResponse(cacheId string, requestURL string, requestHeaders []*CacheStorageHeader) (*CacheStorageCachedResponse, error) {
	var v CacheStorageRequestCachedResponseParams
	v.CacheId = cacheId
	v.RequestURL = requestURL
	v.RequestHeaders = requestHeaders
	return c.RequestCachedResponseWithParams(&v)
}
782205
func (h *Handler) updateCache(request *Request) (*cacheEntry, error) {

	updateAddr := request.Addr()
	log.Trace("feed cache update", "topic", request.Topic.Hex(), "updateaddr", updateAddr, "epoch time", request.Epoch.Time, "epoch level", request.Epoch.Level)

	feedUpdate := h.get(&request.Feed)
	if feedUpdate == nil {
		feedUpdate = &cacheEntry{}
		h.set(&request.Feed, feedUpdate)
	}

	// update our rsrcs entry map
	feedUpdate.lastKey = updateAddr
	feedUpdate.Update = request.Update
	feedUpdate.Reader = bytes.NewReader(feedUpdate.data)
	return feedUpdate, nil
}
998502
func (f *Favorites) RefreshCache(ctx context.Context) {
	if f.disabled || f.hasShutdown() {
		return
	}
	// This request is non-blocking, so use a throw-away done channel
	// and context.
	req := &favReq{
		refresh: true,
		done:    make(chan struct{}),
		ctx:     context.Background(),
	}
	f.wg.Add(1)
	select {
	case f.reqChan <- req:
	case <-ctx.Done():
		f.wg.Done()
		return
	}
}
1031629
func (user *User) UpdateCache(key string, update interface{}, res interface{}) error {

	exists := user.ctx.updateCacheVal("user", key, update, res)

	if !exists {
		log.WithField("key", key).Error("Can't update user cache value")
	}
	return nil
}