예제 #1
0
def main():
    glb = rg_global.RgGlobal('sync_demo')
    glb.connect_sync(rg_mom_common.Db.RGMOMD_HOST)
    mom = rg_mom_sync.RgMomSync(glb)
    master = rg_thread.RgThreadMaster(glb)

    demo = mom_test.Demo()
    demo.index = mom_test.DemoIndex()
    demo.index.index1 = '111'
    demo.index.index2 = '111'
    demo.v1 = 1.111
    mom.lpush(rg_mom_common.Db.RGMOMD_HOST, demo, 1)

    demo2 = mom_test.Demo()
    demo2.index = mom_test.DemoIndex()
    demo2.index.index1 = '111'
    demo2.index.index2 = '111'
    demo2.v1 = 2.222

    # 不应该报入参错误
    mom.linsert(rg_mom_common.Db.RGMOMD_HOST, demo, demo2, 1)

    def cb(t):
        os._exit(0)

    master.add_timer(cb, None, 1)
    glb.run()
예제 #2
0
def main():
    glb = rg_global.RgGlobal('sync_demo')
    glb.connect_sync(rg_mom_common.Db.RGMOMD_HOST)
    mom = rg_mom_sync.RgMomSync(glb)
    master = rg_thread.RgThreadMaster(glb)

    demo = mom_test.Demo()
    demo.index = mom_test.DemoIndex()
    demo.index.index1 = '111'
    demo.index.index2 = '111'
    demo.v1 = 1.111
    ret = mom.lpop(rg_mom_common.Db.RGMOMD_HOST, demo)
    assert (ret == None)
    ret = mom.rpop(rg_mom_common.Db.RGMOMD_HOST, demo)
    assert (ret == None)

    mom.lpush(rg_mom_common.Db.RGMOMD_HOST, demo, 1)
    mom.lpush(rg_mom_common.Db.RGMOMD_HOST, demo, 1)
    ret = mom.lpop(rg_mom_common.Db.RGMOMD_HOST, demo)
    assert (ret != None)
    ret = mom.rpop(rg_mom_common.Db.RGMOMD_HOST, demo)
    assert (ret != None)

    ret, _, _ = mom.hgetall(rg_mom_common.Db.RGMOMD_HOST, demo)
    assert (ret == None)
    ret, _, _ = mom.hmget(rg_mom_common.Db.RGMOMD_HOST, demo, [6, 7])
    assert (ret == None)

    def cb(t):
        os._exit(0)

    master.add_timer(cb, None, 1)
    glb.run()
예제 #3
0
 def setUp(self):
     self.glb = rg_global.RgGlobal('sync_demo')
     if self.glb.connect_sync(Db.RGMOMD_HOST) != 0:
         sys.exit()
     self.db = Db.RGMOMD_HOST
     self.mom = rg_mom_sync.RgMomSync(self.glb)
     self.demo = app_demo.Demo()
     self.demo.index = app_demo.DemoIndex()
     self.demo.index.index1 = '111'
     self.demo.index.index2 = '222'
예제 #4
0
def main():
    glb = rg_global.RgGlobal('sync_demo')
    glb.connect_sync(rg_mom_common.Db.RGMOMD_HOST)
    mom = rg_mom_sync.RgMomSync(glb)
    master = rg_thread.RgThreadMaster(glb)

    demo = mom_test.Demo()
    demo.index = mom_test.DemoIndex()
    demo.index.index1 = '111'
    demo.index.index2 = '111'

    ret, fields, change_fields = mom.hmget(rg_mom_common.Db.RGMOMD_HOST, demo,
                                           [6, 7])
    # 对于不存在的key,返回值应该是None
    assert (ret == None)

    def cb(t):
        os._exit(0)

    master.add_timer(cb, None, 1)
    glb.run()
예제 #5
0
 def setUp(self):
     self.glb = rg_global.RgGlobal('sync_demo')
     if self.glb.connect_sync(Db.RGMOMD_HOST) != 0:
         sys.exit()
     self.db = Db.RGMOMD_HOST
     self.mom = rg_mom_sync.RgMomSync(self.glb)
예제 #6
0
 def setUp(self):
     self.db = Db.RGMOMD_HOST
     self.glb = rg_global.RgGlobal('py_proto_ut')
     self.glb.connect_sync(Db.RGMOMD_HOST)
     self.mom = rg_mom_sync.RgMomSync(self.glb)