mirror of
https://gitee.com/johng/gf
synced 2026-06-07 02:12:11 +08:00
fix(database/gredis): gredis support get raw client (#4306)
Fixes https://github.com/gogf/gf/issues/4298 Fixes https://github.com/gogf/gf/issues/2196 Fixes https://github.com/gogf/gf/issues/2135 ```go import goredis "github.com/redis/go-redis/v9" func ExampleUsage(ctx context.Context, redis *Redis) error { client := redis.Client() universalClient, ok := client.(goredis.UniversalClient) if !ok { return errors.New("failed to assert to UniversalClient") } // Use universalClient for advanced operations like Pipeline pipe := universalClient.Pipeline() pipe.Set(ctx, "key1", "value1", 0) pipe.Set(ctx, "key2", "value2", 0) results, err := pipe.Exec(ctx) if err != nil { return err } // ... handle results return nil } ``` --------- Co-authored-by: hailaz <739476267@qq.com>
This commit is contained in:
@ -30,6 +30,10 @@ type AdapterGroup interface {
|
||||
GroupString() IGroupString
|
||||
}
|
||||
|
||||
// RedisRawClient is a type alias for any, representing the raw underlying redis client.
|
||||
// Implementations should return their concrete client type as this interface.
|
||||
type RedisRawClient any
|
||||
|
||||
// AdapterOperation is the core operation functions for redis.
|
||||
// These functions can be easily overwritten by custom implements.
|
||||
type AdapterOperation interface {
|
||||
@ -43,6 +47,11 @@ type AdapterOperation interface {
|
||||
|
||||
// Close closes current redis client, closes its connection pool and releases all its related resources.
|
||||
Close(ctx context.Context) (err error)
|
||||
|
||||
// Client returns the underlying redis client instance.
|
||||
// This method provides access to the raw redis client for advanced operations
|
||||
// that are not covered by the standard redis adapter interface.
|
||||
Client() RedisRawClient
|
||||
}
|
||||
|
||||
// Conn is an interface of a connection from universal redis client.
|
||||
|
||||
Reference in New Issue
Block a user