func thread(conn redis.Conn, count int, ch chan int) { t1 := time.Now() for i := 0; i < count; i++ { rndid := 1000000 + rand.Intn(75000000) remoteid := strconv.Itoa(rndid) conn.Do("GET", "user:"******":profile") // conn.Do("GET", "user:"******":password") // conn.Do("GET", "user:"******":cflag") // conn.Do("GET", "user:"******":sessionid") // conn.Do("GET", "user:"******":uid") // num := 20000000 + rand.Intn(2000000)*10 + rand.Intn(4) // reply, _ := conn.Do("aof_push_async", "user:"******":history", strconv.Itoa(num)) // if reply == nil { // fmt.Println(reply) // } //conn.Do("SET", "user:"******":sex_f_m", "FM..FM..FM..") // if e1 == nil { // if reply != nil { // fmt.Println(string(reply.([]byte))) // } // } incrCounter() } ch <- 1 t2 := time.Now() fmt.Println("Done in:", t2.Sub(t1)) }
func readFromRedis(conn redis.Conn) { reply, err := conn.Do("GET", "file1") if err != nil { panic(err) } data := reply.([]byte) if err := ioutil.WriteFile("/Volumes/Private MBP/2.jpg", data, os.ModePerm); err != nil { panic(err) } }
func writeToRedis(conn redis.Conn) { data, err := ioutil.ReadFile("/Volumes/Private MBP/0tumblr_mz607.jpg") if err != nil { panic(err) } if reply, err := conn.Do("SET", "file1", data); err != nil { panic(err) } else { fmt.Println(reply) } }