You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+91Lines changed: 91 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,6 +78,97 @@ func main() {
78
78
79
79
```
80
80
81
+
## Using Existing Redis Client
82
+
83
+
If you already have an existing Redis client instance (e.g., due to restricted access to connection details or centralized Redis setup), you can reuse it to create a watcher.
84
+
85
+
### With Regular Redis Client
86
+
87
+
```go
88
+
package main
89
+
90
+
import (
91
+
"fmt"
92
+
93
+
"github.com/casbin/casbin/v3"
94
+
rediswatcher "github.com/casbin/redis-watcher/v2"
95
+
"github.com/redis/go-redis/v9"
96
+
)
97
+
98
+
funcmain() {
99
+
// Create your own Redis client
100
+
redisClient:= redis.NewClient(&redis.Options{
101
+
Addr: "localhost:6379",
102
+
Password: "",
103
+
DB: 0,
104
+
})
105
+
106
+
// Initialize the watcher with existing client
107
+
// Pass empty string for addr since the SubClient and PubClient are already provided
0 commit comments