示例#1
0
文件: scan.go 项目: cxuhua/radix.v2
// scanCluster is like Scan except it operates over a whole cluster. Unlike Scan
// it only works with SCAN and as such only takes in a pattern string.
func scanCluster(c *cluster.Cluster, ch chan string, pattern string) error {
	defer close(ch)
	clients, err := c.GetEvery()
	if err != nil {
		return err
	}
	for _, client := range clients {
		defer c.Put(client)
	}

	for _, client := range clients {
		cch := make(chan string)
		var err error
		go func() {
			err = scanSingle(client, cch, "SCAN", "", pattern)
		}()
		for key := range cch {
			ch <- key
		}
		if err != nil {
			return err
		}
	}

	return nil
}
示例#2
0
func doGetSet(c *cluster.Cluster, key string) {
	if err := c.Cmd("GET", key).Err; err != nil {
		log.Printf("GET %s -> %s", key, err)
	}
	val := randString()
	if err := c.Cmd("SET", key, val).Err; err != nil {
		log.Printf("SET %s %s -> %s", key, val, err)
	}
}