MCPcopy Create free account
hub / github.com/baidu/EasyFaaS / Save

Method Save

pkg/util/cache/cache.go:981–995  ·  view source on GitHub ↗

Write the cache's items (using Gob) to an io.Writer. NOTE: This method is deprecated in favor of c.Items() and NewFrom() (see the documentation for NewFrom().)

(w io.Writer)

Source from the content-addressed store, hash-verified

979// NOTE: This method is deprecated in favor of c.Items() and NewFrom() (see the
980// documentation for NewFrom().)
981func (c *cache) Save(w io.Writer) (err error) {
982 enc := gob.NewEncoder(w)
983 defer func() {
984 if x := recover(); x != nil {
985 err = fmt.Errorf("Error registering item types with Gob library")
986 }
987 }()
988 c.mu.RLock()
989 defer c.mu.RUnlock()
990 for _, v := range c.items {
991 gob.Register(v.Object)
992 }
993 err = enc.Encode(&c.items)
994 return
995}
996
997// Save the cache's items to the given filename, creating the file if it
998// doesn't exist, and overwriting it if it does.

Callers 3

SaveFileMethod · 0.95
testFillAndSerializeFunction · 0.80

Calls 2

EncodeMethod · 0.95
ErrorfMethod · 0.80

Tested by 2

testFillAndSerializeFunction · 0.64