// GetReset  changes the value of an entry into the cache and updates the timestamp
187123
func (c *Cache) GetReset(u interface{}, duration time.Duration) (interface{}, error) {

	c.Lock()
	defer c.Unlock()

	if line, ok := c.data[u]; ok {

		if c.lifetime != -1 && line.timer != nil {
			if duration > 0 {
				line.timer.Reset(duration)
			} else {
				line.timer.Reset(c.lifetime)
			}
		}

		return line.value, nil
	}

	return nil, errors.New("cannot read item: not found")
}
1102539
func (c *randomEvictedCache) Get(key Measurable) (data Measurable, ok bool) {
	c.mu.RLock()
	defer c.mu.RUnlock()
	memoized, ok := c.data[key]
	if !ok {
		return nil, false
	}
	return memoized.m, ok
}
380720
func (c *SimpleLRUCache) Get(key string) (interface{}, bool) {
	data, ok := c.lruCache.Get(key)
	if data != nil && ok {
		var item cacheItem
		item, _ = data.(cacheItem)
		item.expires = timeFunc().Add(c.expiration) // update the expiration
		c.lruCache.Add(key, item)
		return item.value, true
	}
	return nil, false
}
186783
func (ai *AtomicInt) GetAndSet(newValue int) int {
	res := int(atomic.SwapInt64(&ai.val, int64(newValue)))
	return res
}
397356
func (c *LRUExpireCache) Get(key interface{}) (interface{}, bool) {
	c.lock.Lock()
	defer c.lock.Unlock()
	e, ok := c.cache.Get(key)
	if !ok {
		return nil, false
	}
	if c.clock.Now().After(e.(*cacheEntry).expireTime) {
		c.cache.Remove(key)
		return nil, false
	}
	return e.(*cacheEntry).value, true
}
220198
func (met *Metrics) FetchAndReset(keys ...string) map[string]int64 {
	state := make(map[string]int64)

	met.storeGuard.Lock()
	for _, key := range keys {
		if val, exists := met.store[key]; exists {
			state[key] = *val
			*val = 0
		}
	}
	met.storeGuard.Unlock()

	met.rateGuard.Lock()
	for _, key := range keys {
		if rate, exists := met.rates[key]; exists {
			rate.lastSample = 0
			rate.value = 0
			rate.index = 0
			rate.samples.Set(0)
		}
	}
	met.rateGuard.Unlock()

	return state
}
125541
func (c *MemoryCache) Get(key string) (resp []byte, ok bool) {
	c.mu.RLock()
	resp, ok = c.items[key]
	c.mu.RUnlock()
	return resp, ok
}
1125893
func (c *memoryCache) Get(key string) ([]byte, error) {
	c.RLock()
	defer c.RUnlock()

	cached, ok := c.cache[key]
	if ok {
		return cached, nil
	}

	return nil, nil
}
710863
func (c *unfurlCache) get(key string) (res cacheItem, ok bool) {
	c.Lock()
	defer c.Unlock()

	item, ok := c.cache.Get(key)
	if !ok {
		return res, false
	}
	cacheItem, ok := item.(cacheItem)
	if !ok {
		return res, false
	}
	valid := c.clock.Now().Sub(cacheItem.ctime.Time()) <= defaultCacheLifetime
	if !valid {
		c.cache.Remove(key)
	}
	return cacheItem, valid
}
13715
func (cm *cacheManager) get(ctx context.Context, id string, fromSnapshotter bool, opts ...RefOption) (ImmutableRef, error) {
	rec, err := cm.getRecord(ctx, id, fromSnapshotter, opts...)
	if err != nil {
		return nil, err
	}
	rec.mu.Lock()
	defer rec.mu.Unlock()

	triggerUpdate := true
	for _, o := range opts {
		if o == NoUpdateLastUsed {
			triggerUpdate = false
		}
	}

	if rec.mutable {
		if len(rec.refs) != 0 {
			return nil, errors.Wrapf(ErrLocked, "%s is locked", id)
		}
		if rec.equalImmutable != nil {
			return rec.equalImmutable.ref(triggerUpdate), nil
		}
		return rec.mref(triggerUpdate).commit(ctx)
	}

	return rec.ref(triggerUpdate), nil
}
1002521
func (l *Lazy) Get(key string) (interface{}, bool, error) {
	l.init()
	if l.initErr != nil {
		return nil, false, l.initErr
	}
	v, found := l.cache[key]
	return v, found, nil
}
189824
func (s *Settings) Get(c context.Context, key string, value interface{}) error {
	bundle, err := s.values.Get(c, func(interface{}) (interface{}, time.Duration, error) {
		c, done := clock.WithTimeout(c, 15*time.Second) // retry for 15 sec total
		defer done()
		var bundle *Bundle
		var exp time.Duration
		err := retry.Retry(c, transient.Only(retry.Default), func() (err error) {
			c, done := clock.WithTimeout(c, 2*time.Second) // trigger a retry after 2 sec RPC timeout
			defer done()
			bundle, exp, err = s.storage.FetchAllSettings(c)
			return
		}, nil)
		if err != nil {
			return nil, 0, err
		}
		// Meaning of 0 in FetchAllSettings is different from how lazyslot
		// understands it.
		if exp == 0 {
			exp = lazyslot.ExpiresImmediately
		}
		return bundle, exp, nil
	})
	if err != nil {
		return err
	}
	return bundle.(*Bundle).get(key, value)
}
402619
func (c *Identify2Cache) Get(uid keybase1.UID, gctf GetCheckTimeFunc, gcdf GetCacheDurationFunc, breaksOK bool) (*keybase1.Identify2ResUPK2, error) {
	v, err := c.cache.Get(string(uid))
	if err != nil {
		if err == ramcache.ErrNotFound {
			return nil, nil
		}
		return nil, err
	}
	up, ok := v.(*keybase1.Identify2ResUPK2)
	if !ok {
		return nil, fmt.Errorf("invalid type in cache: %T", v)
	}

	if gctf != nil {
		then := gctf(*up)
		if then == 0 {
			return nil, IdentifyTimeoutError{}
		}
		if up.TrackBreaks != nil && !breaksOK {
			return nil, TrackBrokenError{}
		}

		thenTime := keybase1.FromTime(then)
		timeout := gcdf(*up)
		if time.Since(thenTime) > timeout {
			return nil, IdentifyTimeoutError{}
		}
	}

	return up, nil
}
1280188
func (c *MemoryStore) Get(key string) (interface{}, error) {
	item, _ := c.cache.Get(key)
	return item, nil
}
209017
func (c *Cache) Get(ctx context.Context, key storage.CacheKey) ([]byte, bool) {
	c.mu.Lock()
	defer c.mu.Unlock()

	v, ok := c.cacheMap[key]
	return v, ok
}
80951
func (c Cache) Get(k interface{}) (interface{}, bool) {
	v, ok := c[k]
	return v, ok
}
884433
func (c *Client) StatsReset() (err error) {
	_, err = c.StatsWithKey("reset")
	return err
}