Browse Source

update cahce ping

ls 7 months ago
parent
commit
a0b1e5f40a
1 changed files with 28 additions and 9 deletions
  1. 28 9
      cache/redis.go

+ 28 - 9
cache/redis.go

@@ -116,6 +116,14 @@ func NewRedisClusterCache() *RedisCache {
 	return &RedisCache{cc: client}
 }
 
+// Get get value from cache
+func (c RedisCache) Ping() (string, error) {
+	if c.cc != nil {
+		return c.cc.Ping().Result()
+	}
+	return c.c.Ping().Result()
+}
+
 // Get get value from cache
 func (c RedisCache) Get(key string) (string, error) {
 	if c.cc != nil {
@@ -201,6 +209,26 @@ func connect() (*RedisCache, error) {
 	return cache, err
 }
 
+// Ping ping
+func Ping() (string, error) {
+	c, err := connect()
+	if err != nil {
+		return "", err
+	}
+
+	return c.Ping()
+}
+
+// Info info
+func Info() (string, error) {
+	c, err := connect()
+	if err != nil {
+		return "", err
+	}
+
+	return c.Info()
+}
+
 // Get key from cache
 func Get(key string) (string, error) {
 	c, err := connect()
@@ -228,15 +256,6 @@ func Del(key string) (int64, error) {
 	return c.Del(key)
 }
 
-func Info() (string, error) {
-	c, err := connect()
-	if err != nil {
-		return "", err
-	}
-
-	return c.Info()
-}
-
 // Publish publish message
 func Publish(channel, message string) error {
 	c, err := connect()