MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / RedisHSetField

Function RedisHSetField

common/redis.go:302–327  ·  view source on GitHub ↗
(key, field string, value interface{})

Source from the content-addressed store, hash-verified

300}
301
302func RedisHSetField(key, field string, value interface{}) error {
303 if DebugEnabled {
304 SysLog(fmt.Sprintf("Redis HSET field: key=%s, field=%s, value=%v", key, field, value))
305 }
306 ttlCmd := RDB.TTL(context.Background(), key)
307 ttl, err := ttlCmd.Result()
308 if err != nil && !errors.Is(err, redis.Nil) {
309 return fmt.Errorf("failed to get TTL: %w", err)
310 }
311
312 if ttl > 0 {
313 ctx := context.Background()
314 txn := RDB.TxPipeline()
315
316 hsetCmd := txn.HSet(ctx, key, field, value)
317 if err := hsetCmd.Err(); err != nil {
318 return err
319 }
320
321 txn.Expire(ctx, key, ttl)
322
323 _, err = txn.Exec(ctx)
324 return err
325 }
326 return nil
327}

Callers 6

updateUserStatusCacheFunction · 0.92
updateUserQuotaCacheFunction · 0.92
updateUserGroupCacheFunction · 0.92
updateUserNameCacheFunction · 0.92
updateUserSettingCacheFunction · 0.92
cacheSetTokenFieldFunction · 0.92

Calls 1

SysLogFunction · 0.85

Tested by

no test coverage detected