123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- package redis
- import (
- "log"
- "testing"
- "time"
- )
- func Test_redis(t *testing.T) {
- InitRedis("192.168.3.142:6379,192.168.3.142:7379")
- log.Println(PutKV("key-BBB", "v-oooo"))
- log.Println(GetStr("", "key-BBB"))
- log.Println(PutCKV("code-K", "key-BBB2", 123))
- log.Println(GetInt("code-K", "key-BBB2"))
- log.Println(Put("codeA", "BBB", "oooo", 0))
- //log.Println(Del("codeA", "AAA"))
- log.Println(GetStr("codeA", "AAA"))
- log.Println(Put("code", "Key", &map[string]string{"name": "张三"}, 0))
- log.Println(Get("code", "Key"))
- }
- func Test_redisMorePut(t *testing.T) {
- //by := []byte("dddddddddddd555d")
- //InitRedis("enterprise=192.168.3.14:1379,service=192.168.3.14:2379,other=192.168.3.14:3379")
- InitRedis("sso=192.168.3.14:1379")
- //PutBytes("enterprise", "A", &by, 0)
- //Put("sso", "new_1070776706", "obEpLuMMDUYUM-zlzCbQ0MbuQOzc", 180)
- Put("sso", "1903540616", "oJULtwzXo6EFV1Ah-XeyRBimXGM8", 180)
- //log.Println(Get("enterprise", "A"))
- //GetMoreKey("ent*")
- }
- func Test_other(t *testing.T) {
- //s := `[{"S_remark":"kokopkopkop","s_pic":"/upload/2015/10/16/2015101611194101018681.jpg","o_extend":{"k1":"ioio","k7":"000"}}]`
- //mo := []map[string]interface{}{}
- //json.Unmarshal([]byte(s), &mo)
- //log.Println(mo)
- pools := make(chan bool, 1)
- pool := make(chan bool, 2)
- for i := 0; i < 1000; i++ {
- go func(i int) {
- pool <- true
- defer func() {
- <-pool
- }()
- log.Println("--", i)
- time.Sleep(5 * time.Millisecond)
- }(i)
- }
- <-pools
- }
- func TestIncr(t *testing.T) {
- InitRedis("sso=192.168.3.14:1379")
- log.Println(Incr("sso", "user"))
- }
|