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

Function NewInteractiveCache

internal/repository/cache/interactive.go:41–58  ·  view source on GitHub ↗
(client redis.Cmdable)

Source from the content-addressed store, hash-verified

39}
40
41func NewInteractiveCache(client redis.Cmdable) InteractiveCache {
42 locker := redislock.New(client)
43
44 // 将 Lua 脚本加载到 Redis 中,并保存其 SHA1 值以便后续调用
45 incrByScript := redis.NewScript(`
46local key = KEYS[1]
47local field = ARGV[1]
48local increment = tonumber(ARGV[2])
49local value = redis.call("HINCRBY", key, field, increment)
50return value
51`)
52
53 return &interactiveCache{
54 client: client,
55 locker: locker,
56 incrByScript: incrByScript,
57 }
58}
59
60// Get 获取互动信息
61func (i *interactiveCache) Get(ctx context.Context, postId uint) (domain.Interactive, error) {

Callers 1

InitWebServerFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected