MCPcopy Create free account
hub / github.com/patrickmn/go-cache / SaveFile

Method SaveFile

cache.go:984–995  ·  view source on GitHub ↗

Save the cache's items to the given filename, creating the file if it doesn't exist, and overwriting it if it does. NOTE: This method is deprecated in favor of c.Items() and NewFrom() (see the documentation for NewFrom().)

(fname string)

Source from the content-addressed store, hash-verified

982// NOTE: This method is deprecated in favor of c.Items() and NewFrom() (see the
983// documentation for NewFrom().)
984func (c *cache) SaveFile(fname string) error {
985 fp, err := os.Create(fname)
986 if err != nil {
987 return err
988 }
989 err = c.Save(fp)
990 if err != nil {
991 fp.Close()
992 return err
993 }
994 return fp.Close()
995}
996
997// Add (Gob-serialized) cache items from an io.Reader, excluding any items with
998// keys that already exist (and haven't expired) in the current cache.

Callers 1

TestFileSerializationFunction · 0.80

Calls 1

SaveMethod · 0.95

Tested by 1

TestFileSerializationFunction · 0.64