code: 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
  }
docs: // 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.