恢复数据库对象与redis对象的返回

This commit is contained in:
2025-11-30 16:03:50 +08:00
parent d454d8e143
commit fd37c5c301
4 changed files with 90 additions and 8 deletions

View File

@@ -239,9 +239,13 @@ fac.RedisSet(ctx, "key", "value", time.Hour)
value, _ := fac.RedisGet(ctx, "key")
fac.RedisDelete(ctx, "key")
// 数据库(GORM已经很灵活直接返回对象)
// 数据库(黑盒模式,获取已初始化对象)
db, _ := fac.GetDatabase()
db.Find(&users)
// Redis客户端黑盒模式获取已初始化对象
redisClient, _ := fac.GetRedisClient()
redisClient.HGet(ctx, "key", "field").Result()
```
更多示例请查看 [examples](./examples/) 目录。