Example #1
0
func main() {
	log.Println("Main")
	conn, err := ssdb.Connect("127.0.0.1", 8888)
	log.Println(conn, err)
	//w := Writer{10000, conn}
	//log.Println(w)
	//w.Run()
	now := time.Now()
	numberOfWorker := 3
	var wg sync.WaitGroup
	wg.Add(numberOfWorker)
	for i := 0; i < numberOfWorker; i++ {
		go func(i int, conn *ssdb.Client, wg *sync.WaitGroup) {
			w := Writer{100000, conn}
			w.Run()
			log.Println("Writer", i, "finished")
			wg.Done()
		}(i, conn, &wg)

	}

	wg.Wait()

	log.Println(numberOfWorker, "Writer", "took", time.Now().Sub(now))

}
Example #2
0
func (p *SsdbProvider) connectInit() error {
	var err error
	if p.host == "" || p.port == 0 {
		return errors.New("SessionInit First")
	}
	p.client, err = ssdb.Connect(p.host, p.port)
	if err != nil {
		return err
	}
	return nil
}
Example #3
0
// connect to memcache and keep the connection.
func (rc *Cache) connectInit() error {
	conninfoArray := strings.Split(rc.conninfo[0], ":")
	host := conninfoArray[0]
	port, e := strconv.Atoi(conninfoArray[1])
	if e != nil {
		return e
	}
	var err error
	rc.conn, err = ssdb.Connect(host, port)
	if err != nil {
		return err
	}
	return nil
}
Example #4
0
//打开连接
func (this *Client) Start() error {
	if this.isOpen {
		return nil
	}
	//log.Println("set pwd", AuthPassword)
	this.password = AuthPassword
	db, err := ssdb.Connect(this.pool.cfg.Host, this.pool.cfg.Port)
	if err != nil {
		return err
	}
	this.lastTime = time.Now()
	this.isOpen = true
	this.Client = *db
	return nil
}