// GAT (get and touch) retrieves the value associated with the key and updates
// its expiration time.
179124
func (c *Client) GAT(key string, exp uint32) (val string, flags uint32, cas uint64, err error) {
	// Variants: GAT [Q, K, KQ]
	// Request : MUST key, extras; MUST NOT value
	// Response: MAY key, value, extras ([0..3] flags)
	m := &msg{
		header: header{
			Op: opGAT,
		},
		iextras: []interface{}{exp},
		oextras: []interface{}{&flags},
		key:     key,
	}

	err = c.perform(m)
	return m.val, flags, m.CAS, err
}
707878
func (mBatch *goLevelDBBatch) Set(key, value []byte) {
	mBatch.batch.Put(key, value)
}
704322
func (cache *Cache) Set(key string, data string) {
	cache.mutex.Lock()
	item := &Item{data: data}
	item.touch(cache.ttl)
	cache.items[key] = item
	cache.mutex.Unlock()
}
190100
func (g *Goon) Get(dst interface{}) error {
	set := reflect.ValueOf(dst)
	if set.Kind() != reflect.Ptr {
		return fmt.Errorf("goon: expected pointer to a struct, got %#v", dst)
	}
	if !set.CanSet() {
		set = set.Elem()
	}
	dsts := []interface{}{dst}
	if err := g.GetMulti(dsts); err != nil {
		// Look for an embedded error if it's multi
		if me, ok := err.(appengine.MultiError); ok {
			return me[0]
		}
		// Not multi, normal error
		return err
	}
	set.Set(reflect.Indirect(reflect.ValueOf(dsts[0])))
	return nil
}
973530
func touch(path string) {
	t := time.Now()
	if err := os.Chtimes(path, t, t); err != nil {
		log.Printf("failed to touch %s: %s", path, err)
	}
}
649889
func (mem *Memory) Get(key string) interface{} {
	if ret, ok := mem.data[key]; ok {
		if ret.Expired.Before(time.Now()) {
			mem.deleteKey(key)
			return nil
		}
		return ret.Data
	}
	return nil
}
771978
func (r *RedisCache) Touch(key string, expire int64) (err error) {
	if _, err = r.do("EXPIRE", key, expire); err != nil {
		return
	}

	if r.occupyMode {
		return
	}

	_, err = r.do("HSET", r.key(GC_HASH_KEY), r.key(key), (time.Now().Unix() + expire))

	return nil
}
844362
func (c *ExpireCache) Get(key interface{}) (interface{}, bool) {
	c.mutex.Lock()
	defer c.mutex.Unlock()

	record, ok := c.cache[key]
	if !ok {
		c.stats.Miss++
		return nil, ok
	}

	// Since this was recently accessed, keep it in
	// the cache by resetting the expire time
	record.ExpireAt = time.Now().UTC().Add(c.ttl)

	c.stats.Hit++
	return record.Value, ok
}
386248
func (s *tikvSnapshot) Get(k kv.Key) ([]byte, error) {
	ctx := context.WithValue(context.Background(), txnStartKey, s.version.Ver)
	val, err := s.get(NewBackoffer(ctx, getMaxBackoff), k)
	if err != nil {
		return nil, errors.Trace(err)
	}
	if len(val) == 0 {
		return nil, kv.ErrNotExist
	}
	return val, nil
}
1195621
func (c *Client) GetSet(key, value string) (string, error) {
	v, err := c.execWithKey(true, "GETSET", key, value)
	if err != nil {
		return "", err
	}
	return iface2str(v)
}
38553
func (c *RawKVClient) Put(key, value []byte) error {
	start := time.Now()
	defer func() { tikvRawkvCmdHistogramWithBatchPut.Observe(time.Since(start).Seconds()) }()
	tikvRawkvSizeHistogramWithKey.Observe(float64(len(key)))
	tikvRawkvSizeHistogramWithValue.Observe(float64(len(value)))

	if len(value) == 0 {
		return errors.New("empty value is not supported")
	}

	req := &tikvrpc.Request{
		Type: tikvrpc.CmdRawPut,
		RawPut: &kvrpcpb.RawPutRequest{
			Key:   key,
			Value: value,
		},
	}
	resp, _, err := c.sendReq(key, req, false)
	if err != nil {
		return errors.Trace(err)
	}
	cmdResp := resp.RawPut
	if cmdResp == nil {
		return errors.Trace(ErrBodyMissing)
	}
	if cmdResp.GetError() != "" {
		return errors.New(cmdResp.GetError())
	}
	return nil
}
299533
func (b *Bucket) Touch(key string, cas Cas, expiry uint32) (Cas, error) {
	cas, _, err := b.touch(key, cas, expiry)
	return cas, err
}
784429
func updateDict(dict *Dict, updates Tuple, kwargs []Tuple) error {
	if len(updates) == 1 {
		switch updates := updates[0].(type) {
		case NoneType:
			// no-op
		case *Dict:
			// Iterate over dict's key/value pairs, not just keys.
			for _, item := range updates.Items() {
				if err := dict.SetKey(item[0], item[1]); err != nil {
					return err // dict is frozen
				}
			}
		default:
			// all other sequences
			iter := Iterate(updates)
			if iter == nil {
				return fmt.Errorf("got %s, want iterable", updates.Type())
			}
			defer iter.Done()
			var pair Value
			for i := 0; iter.Next(&pair); i++ {
				iter2 := Iterate(pair)
				if iter2 == nil {
					return fmt.Errorf("dictionary update sequence element #%d is not iterable (%s)", i, pair.Type())

				}
				defer iter2.Done()
				len := Len(pair)
				if len < 0 {
					return fmt.Errorf("dictionary update sequence element #%d has unknown length (%s)", i, pair.Type())
				} else if len != 2 {
					return fmt.Errorf("dictionary update sequence element #%d has length %d, want 2", i, len)
				}
				var k, v Value
				iter2.Next(&k)
				iter2.Next(&v)
				if err := dict.SetKey(k, v); err != nil {
					return err
				}
			}
		}
	}

	// Then add the kwargs.
	for _, pair := range kwargs {
		if err := dict.SetKey(pair[0], pair[1]); err != nil {
			return err // dict is frozen
		}
	}

	return nil
}
1052972
func (i *Issue) GetUpdatedAt() time.Time {
	if i == nil || i.UpdatedAt == nil {
		return time.Time{}
	}
	return *i.UpdatedAt
}
337138
func (d *Delay) GetExpiration(key string) time.Time {
	d.lock.RLock()
	expires := d.delay[key]
	d.lock.RUnlock()
	return expires
}
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)
}
450284
func (n *Notification) GetUpdatedAt() time.Time {
	if n == nil || n.UpdatedAt == nil {
		return time.Time{}
	}
	return *n.UpdatedAt
}