package main import ( "fmt" "log" "strconv" "time" "github.com/garyburd/redigo/redis" ) func mget() { conn := dbs.rdb.Get() defer conn.Close() for { get := <-mget_chan start := time.Now() uq := make([]userQuota, 0) for _, key := range get { // estrae un userid dalla lista degli utenti che hanno fatto login quota, err := redis.Strings(conn.Do("mget", fmt.Sprintf("%s@tiscali.it/quota/messages", key), fmt.Sprintf("%s@tiscali.it/quota/storage", key))) // se non ci sono piu' userid esce if err != nil { if opts.Debug { fmt.Printf("MGET err: %v\n", err) } log.Printf("MGET err: %v\n", err) continue } counter <- Counterchan{ tipo: "user", val: 1, } msg, err := strconv.Atoi(quota[0]) if err != nil { msg = 0 } store, err := strconv.Atoi(quota[1]) if err != nil { store = 0 } uq = append(uq, userQuota{ user: key, messages: msg, storage: store, }) } if opts.Debug { fmt.Printf("\nMGET: %+v\n", time.Since(start)) } wg.Add(1) consume <- uq wg.Done() } }