// Put caches an instance.
//
// write must write the instance contents. May remove some instances from the
// cache that were not accessed for a long time.
511811
func (c *InstanceCache) Put(ctx context.Context, pin common.Pin, now time.Time, write func(*os.File) error) error {
	if err := common.ValidatePin(pin, common.AnyHash); err != nil {
		return err
	}
	path, err := c.fs.RootRelToAbs(pin.InstanceID)
	if err != nil {
		return fmt.Errorf("invalid instance ID %q", pin.InstanceID)
	}

	if err := c.fs.EnsureFile(ctx, path, write); err != nil {
		return err
	}

	c.withState(ctx, now, func(s *messages.InstanceCache) {
		touch(s, pin.InstanceID, now)
		c.gc(ctx, s, now)
	})
	return nil
}
948050
func (c *Cache) Put(key string, item *Item) (err error) {
	in := struct {
		Value     interface{} `json:"value"`
		ExpiresIn int         `json:"expires_in,omitempty"`
		Replace   bool        `json:"replace,omitempty"`
		Add       bool        `json:"add,omitempty"`
	}{
		Value:     item.Value,
		ExpiresIn: int(item.Expiration.Seconds()),
		Replace:   item.Replace,
		Add:       item.Add,
	}

	return c.caches(c.Name, "items", key).Req("PUT", &in, nil)
}
131658
func (c *NodbCacher) Put(key string, val interface{}, expire int64) (err error) {
	var v []byte
	switch val.(type) {
	case []byte:
		v = val.([]byte)
	default:
		v = []byte(com.ToStr(val))
	}

	if err = c.db.Set([]byte(key), v); err != nil {
		return err
	}

	if expire > 0 {
		_, err = c.db.Expire([]byte(key), expire)
		return err
	}
	return nil
}
624242
func (cfs *cacheFSObjects) Put(ctx context.Context, bucket, object string, data *PutObjReader, opts ObjectOptions) error {
	if cfs.diskUsageHigh() {
		select {
		case cfs.purgeChan <- struct{}{}:
		default:
		}
		return errDiskFull
	}
	if !cfs.diskAvailable(data.Size()) {
		return errDiskFull
	}
	if _, err := cfs.GetBucketInfo(ctx, bucket); err != nil {
		pErr := cfs.MakeBucketWithLocation(ctx, bucket, "")
		if pErr != nil {
			return pErr
		}
	}
	_, err := cfs.PutObject(ctx, bucket, object, data, opts)
	// if err is due to disk being offline , mark cache drive as offline
	if IsErr(err, baseErrs...) {
		cfs.setOnline(false)
	}
	return err
}
286817
func (wp *WriterPool) Put(bw *bufio.Writer) {
	// Should reset even if we do Reset() inside Get().
	// This is done to prevent locking underlying io.Writer from GC.
	bw.Reset(nil)
	wp.pool.Put(bw, writerSize(bw))
}
982583
func (c *LedisCacher) Put(key string, val interface{}, expire int64) (err error) {
	if expire == 0 {
		if err = c.c.Set([]byte(key), []byte(com.ToStr(val))); err != nil {
			return err
		}
		_, err = c.c.HSet([]byte(key), defaultHSetName, []byte("0"))
		return err
	}

	if err = c.c.SetEX([]byte(key), expire, []byte(com.ToStr(val))); err != nil {
		return err
	}
	_, err = c.c.HSet([]byte(key), defaultHSetName, []byte(com.ToStr(time.Now().Add(time.Duration(expire)*time.Second).Unix())))
	return err
}
672015
func (dbcr *DiskBlockCacheRemote) Put(ctx context.Context, tlfID tlf.ID,
	blockID kbfsblock.ID, buf []byte,
	serverHalf kbfscrypto.BlockCryptKeyServerHalf,
	_ DiskBlockCacheType) (err error) {
	dbcr.log.LazyTrace(ctx, "DiskBlockCacheRemote: Put %s", blockID)
	defer func() {
		dbcr.log.LazyTrace(ctx, "DiskBlockCacheRemote: Put %s done (err=%+v)", blockID, err)
	}()

	return dbcr.client.PutBlock(ctx, kbgitkbfs.PutBlockArg{
		TlfID:      tlfID.Bytes(),
		BlockID:    blockID.Bytes(),
		Buf:        buf,
		ServerHalf: serverHalf.Bytes(),
	})
}
891863
func (d *Driver) Put(id string) error {
	panicIfUsedByLcow()
	logrus.Debugf("WindowsGraphDriver Put() id %s", id)

	rID, err := d.resolveID(id)
	if err != nil {
		return err
	}
	if count := d.ctr.Decrement(rID); count > 0 {
		return nil
	}
	d.cacheMu.Lock()
	_, exists := d.cache[rID]
	delete(d.cache, rID)
	d.cacheMu.Unlock()

	// If the cache was not populated, then the layer was left unprepared and deactivated
	if !exists {
		return nil
	}

	if err := hcsshim.UnprepareLayer(d.info, rID); err != nil {
		return err
	}
	return hcsshim.DeactivateLayer(d.info, rID)
}
241218
func (rc *Redis) Put(key string, value interface{}) error {
	val, err := Encode(value)
	if err != nil {
		if rc.Debug {
			log.Println("[Redis]EncodeErr: ", err, "Key:", key)
		}
		return err
	}
	if _, err = rc.do("SETEX", key, rc.LifeTime, val); err != nil {
		return err
	}
	_, err = rc.do("HSET", rc.key, key, true)
	if err != nil {
		if rc.Debug {
			log.Println("[Redis]PutErr: ", err, "Key:", key)
		}
		return err
	}
	if rc.Debug {
		log.Println("[Redis]Put: ", key)
	}
	return err
}
1148353
func (database *Database) Put(key string, value interface{}) {
	database.db.Put(key, value)
}
939479
func (d *MutexDatastore) Put(key ds.Key, value []byte) (err error) {
	d.Lock()
	defer d.Unlock()
	return d.child.Put(key, value)
}
748745
func (d *Datastore) Put(k ds.Key, val []byte) error {
	return d.runOp(func() error {
		return d.Batching.Put(k, val)
	})
}
819668
func (b *tableBatch) Put(key, value []byte) error {
	return b.batch.Put(append([]byte(b.prefix), key...), value)
}
560675
func (c *MemcacheCacher) Put(key string, val interface{}, expire int64) error {
	return c.c.Set(NewItem(key, []byte(com.ToStr(val)), int32(expire)))
}
1038936
func (cas *ContentAddressedStore) Put(data []byte) ([]byte, error) {
	hasher := sha256.New()
	_, err := hasher.Write(data)
	if err != nil {
		return nil, fmt.Errorf("ContentAddressedStore could not hash data: %v", err)
	}
	hash := hasher.Sum(nil)
	cas.db.SetSync(hash, data)
	return hash, nil
}
13837
func (md *MDCacheStandard) Put(rmd ImmutableRootMetadata) error {
	md.lock.Lock()
	defer md.lock.Unlock()
	key := mdCacheKey{rmd.TlfID(), rmd.Revision(), rmd.BID()}
	if _, ok := md.lru.Get(key); ok {
		// Don't overwrite the cache.  In the case that `rmd` is
		// different from what's in the cache, we require that upper
		// layers manage the cache explicitly by deleting or replacing
		// it explicitly.
		return nil
	}
	md.lru.Add(key, rmd)
	return nil
}
544690
func (s *Session) Put(ctx context.Context, key string, val interface{}) {
	sd := s.getSessionDataFromContext(ctx)

	sd.mu.Lock()
	sd.Values[key] = val
	sd.status = Modified
	sd.mu.Unlock()
}