|
@@ -100,6 +100,16 @@ func NewRedisClusterCache(opt RedisClusterOptions) (rc *RedisCache, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// Reconnect reconnect
|
|
|
+func (c RedisCache) Reconnect() (s string, err error) {
|
|
|
+ if c.cluster {
|
|
|
+ s, err = c.cc.Ping(ctx).Result()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ s, err = c.c.Ping(ctx).Result()
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
// Get get value from cache
|
|
|
func (c RedisCache) Get(k string) (string, error) {
|
|
|
if c.cluster {
|
|
@@ -203,6 +213,11 @@ func SetDefaultRedisClusterOption(opt RedisClusterOptions) (err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// RedisReconnect re connect
|
|
|
+func RedisReconnect() (string, error) {
|
|
|
+ return defaultRedis.Reconnect()
|
|
|
+}
|
|
|
+
|
|
|
// RedisGet get value from cache
|
|
|
func RedisGet(k string) (string, error) {
|
|
|
return defaultRedis.Get(k)
|