src/server/pkg/localcache/cache.go
func (c *Cache) Put(key string, value io.Reader) (retErr error) {
	c.mu.Lock()
	defer c.mu.Unlock()
	f, err := os.Create(filepath.Join(c.root, key))
	if err != nil {
		return err
	}
	defer func() {
		if err := f.Close(); err != nil && retErr == nil {
			retErr = err
		}
	}()
	buf := grpcutil.GetBuffer()
	defer grpcutil.PutBuffer(buf)
	if _, err := io.CopyBuffer(f, value, buf); err != nil {
		return err
	}
	c.keys[key] = true
	return nil
}
func (c *Cache) Put(key string, value io.Reader) (retErr error) {
	c.mu.Lock()
	defer c.mu.Unlock()
	f, err := os.Create(filepath.Join(c.root, key))
	if err != nil {
		return err
	}
	defer func() {
		if err := f.Close(); err != nil && retErr == nil {
			retErr = err
		}
	}()
	buf := grpcutil.GetBuffer()
	defer grpcutil.PutBuffer(buf)
	if _, err := io.CopyBuffer(f, value, buf); err != nil {
		return err
	}
	c.keys[key] = true
	return nil
}
func ( c * Cache ) Put ( key string , value io . Reader ) ( retErr error ) { c . mu . Lock ( ) defer c . mu . Unlock ( ) f , err := os . Create ( filepath . Join ( c . root , key ) ) if err != nil { return err } defer func ( ) { if err := f . Close ( ) ; err != nil && retErr == nil { retErr = err } } ( ) buf := grpcutil . GetBuffer ( ) defer grpcutil . PutBuffer ( buf ) if _ , err := io . CopyBuffer ( f , value , buf ) ; err != nil { return err } c . keys [ key ] = true return nil }
// Put puts a key/value pair in the cache and reads the value from an io.Reader.
Put puts a key / value pair in the cache and reads the value from an io . Reader .