Пример #1
0
func (srv *Server) mIncr(req *Request) {
	var cliType uint32 = ClientTypeNormal
	if req.Cli != nil {
		cliType = req.Cli.ClientType()
	}
	var wa = store.NewWriteAccess(ClientTypeSlave == cliType, srv.mc)
	switch cliType {
	case ClientTypeNormal:
		if !wa.Check() {
			srv.replyMultiOp(req, table.EcWriteSlave)
			return
		}
		pkg, ok := srv.tbl.MIncr(&req.PkgArgs, req.Cli, wa)
		srv.sendResp(ok, req, pkg)
	case ClientTypeSlave:
		pkg, ok := srv.tbl.MIncr(&req.PkgArgs, req.Cli, wa)
		if ok {
			srv.sendResp(ok, req, nil)
		} else {
			srv.sendResp(ok, req, pkg)
		}
	case ClientTypeMaster:
		log.Printf("Slave MINCR failed: [%d, %d]\n", req.DbId, req.Seq)
	}
}
Пример #2
0
func (srv *Server) mGet(req *Request) {
	var cliType uint32 = ClientTypeNormal
	if req.Cli != nil {
		cliType = req.Cli.ClientType()
	}
	var wa = store.NewWriteAccess(ClientTypeSlave == cliType, srv.mc)

	var pkg = srv.tbl.MGet(&req.PkgArgs, req.Cli, wa)
	srv.sendResp(false, req, pkg)
}