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

Method SetCache

internal/repository/cache/relation.go:50–59  ·  view source on GitHub ↗
(ctx context.Context, key string, relations []domain.Relation, ttl time.Duration)

Source from the content-addressed store, hash-verified

48}
49
50func (c *relationCache) SetCache(ctx context.Context, key string, relations []domain.Relation, ttl time.Duration) error {
51 // 编码数据为JSON格式
52 data, err := json.Marshal(relations)
53 if err != nil {
54 return err
55 }
56
57 // 设置缓存并设置过期时间
58 return c.client.Set(ctx, key, data, ttl).Err()
59}
60
61func (c *relationCache) GetCountCache(ctx context.Context, key string) (int64, error) {
62 count, err := c.client.Get(ctx, key).Int64()

Callers

nothing calls this directly

Calls 1

SetMethod · 0.65

Tested by

no test coverage detected