MCPcopy Index your code
hub / github.com/go-dev-frame/sponge / MultiGet

Method MultiGet

internal/cache/userExample.go:110–132  ·  view source on GitHub ↗

MultiGet multiple get cache, return key in map is id value

(ctx context.Context, ids []uint64)

Source from the content-addressed store, hash-verified

108
109// MultiGet multiple get cache, return key in map is id value
110func (c *userExampleCache) MultiGet(ctx context.Context, ids []uint64) (map[uint64]*model.UserExample, error) {
111 var keys []string
112 for _, v := range ids {
113 cacheKey := c.GetUserExampleCacheKey(v)
114 keys = append(keys, cacheKey)
115 }
116
117 itemMap := make(map[string]*model.UserExample)
118 err := c.cache.MultiGet(ctx, keys, itemMap)
119 if err != nil {
120 return nil, err
121 }
122
123 retMap := make(map[uint64]*model.UserExample)
124 for _, id := range ids {
125 val, ok := itemMap[c.GetUserExampleCacheKey(id)]
126 if ok {
127 retMap[id] = val
128 }
129 }
130
131 return retMap, nil
132}
133
134// Del delete cache
135func (c *userExampleCache) Del(ctx context.Context, id uint64) error {

Callers

nothing calls this directly

Calls 2

MultiGetMethod · 0.65

Tested by

no test coverage detected