poco efficente.... implemento iterator

This commit is contained in:
Miki 2015-11-19 17:12:53 +01:00
parent 12a27241f7
commit ba85c9ecc9
4 changed files with 64 additions and 24 deletions

View file

@ -5,6 +5,7 @@ import (
"fmt"
"github.com/garyburd/redigo/redis"
"log"
"time"
)
func producer() {
@ -12,11 +13,12 @@ func producer() {
defer conn.Close()
for loop {
start := time.Now()
// estrae un userid dalla lista degli utenti che hanno fatto login
user, err := redis.String(conn.Do("spop", "llindex"))
if opts.Debug {
log.Printf("SPOP: %+v %+v - conn: %d\n\r", user, err)
fmt.Printf("SPOP: %+v %+v - conn: %d\n\r", user, err)
log.Printf("SPOP: %+v - %+v\n\r", user, err)
fmt.Printf("SPOP: %+v - %+v\n\r", user, err)
}
// se non ci sono piu' userid esce
if err != nil {
@ -27,6 +29,6 @@ func producer() {
break
}
msgs <- user
fmt.Printf("PROD: user=%s in %v - conn=%d\n\r", user, time.Since(start), dbs.rdb.ActiveCount())
}
done <- true
}