MultiGet multiple get cache, return key in map is id value
(ctx context.Context, ids []uint64)
| 108 | |
| 109 | // MultiGet multiple get cache, return key in map is id value |
| 110 | func (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 |
| 135 | func (c *userExampleCache) Del(ctx context.Context, id uint64) error { |
nothing calls this directly
no test coverage detected