Browse Source

增加exists

master
guzeng 2 years ago
parent
commit
627b8d214d
2 changed files with 41 additions and 0 deletions
  1. +23
    -0
      exists.go
  2. +18
    -0
      exists_test.go

+ 23
- 0
exists.go View File

@ -0,0 +1,23 @@
package redis
import (
redisdb "github.com/gomodule/redigo/redis"
)
//exists
func Exists(key string) (bool, error) {
c := pool.Get()
defer c.Close()
return redisdb.Bool(c.Do("EXISTS", key))
}
//hexists
func HExists(key string) (bool, error) {
c := pool.Get()
defer c.Close()
return redisdb.Bool(c.Do("HEXISTS", key))
}

+ 18
- 0
exists_test.go View File

@ -0,0 +1,18 @@
package redis
import (
// "strconv"
"testing"
// "tgo/helper"
)
func Test_Exists(t *testing.T) {
ret3, err := Exists("testing23")
t.Log(ret3)
t.Log(err)
ret3, err := HExists("testing23")
t.Log(ret3)
t.Log(err)
}

Loading…
Cancel
Save