| @ -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)) | |||||
| } | |||||
| @ -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) | |||||
| } | |||||