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

Method Load

pkg/util/cache/cache.go:1020–1035  ·  view source on GitHub ↗

Add (Gob-serialized) cache items from an io.Reader, excluding any items with keys that already exist (and haven't expired) in the current cache. NOTE: This method is deprecated in favor of c.Items() and NewFrom() (see the documentation for NewFrom().)

(r io.Reader)

Source from the content-addressed store, hash-verified

1018// NOTE: This method is deprecated in favor of c.Items() and NewFrom() (see the
1019// documentation for NewFrom().)
1020func (c *cache) Load(r io.Reader) error {
1021 dec := gob.NewDecoder(r)
1022 items := map[string]Item{}
1023 err := dec.Decode(&items)
1024 if err == nil {
1025 c.mu.Lock()
1026 defer c.mu.Unlock()
1027 for k, v := range items {
1028 ov, found := c.items[k]
1029 if !found || ov.Expired() {
1030 c.items[k] = v
1031 }
1032 }
1033 }
1034 return err
1035}
1036
1037// Load and add cache items from the given filename, excluding any items with
1038// keys that already exist in the current cache.

Callers 14

LoadFileMethod · 0.95
ExistMethod · 0.80
getMethod · 0.80
delMethod · 0.80
loadRequestMethod · 0.80
InvokeDoneMethod · 0.80
GetRuntimeMethod · 0.80
setNXMapMethod · 0.80
getMapMethod · 0.80
getMethod · 0.80
setMethod · 0.80
delMethod · 0.80

Calls 3

DecodeMethod · 0.95
LockMethod · 0.80
ExpiredMethod · 0.80

Tested by 1

testFillAndSerializeFunction · 0.64