MCPcopy Create free account
hub / github.com/GoSimplicity/LinkMe / Get

Method Get

internal/repository/cache/interactive.go:61–75  ·  view source on GitHub ↗

Get 获取互动信息

(ctx context.Context, postId uint)

Source from the content-addressed store, hash-verified

59
60// Get 获取互动信息
61func (i *interactiveCache) Get(ctx context.Context, postId uint) (domain.Interactive, error) {
62 key := fmt.Sprintf("interactive:%d", postId)
63 res, err := i.client.HGetAll(ctx, key).Result()
64 if err != nil {
65 return domain.Interactive{}, err
66 }
67 if len(res) == 0 {
68 return domain.Interactive{}, ErrKeyNotExist
69 }
70 var di domain.Interactive
71 di.CollectCount, _ = strconv.ParseInt(res[CollectCount], 10, 64)
72 di.LikeCount, _ = strconv.ParseInt(res[LikeCount], 10, 64)
73 di.ReadCount, _ = strconv.ParseInt(res[ReadCount], 10, 64)
74 return di, nil
75}
76
77// Set 存储互动信息
78func (i *interactiveCache) Set(ctx context.Context, postId uint, res domain.Interactive) error {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected