예제 #1
0
def get_redis_minifeed():
    global logger
    global g_redis_minifeed

    if g_redis_minifeed != None:
        return g_redis_minifeed

    try:
        g_redis_minifeed = libredis.libredis(conf.g_conf['redis_net_assist'],
                                             'minifeed')
        return g_redis_minifeed
    except:
        logger.error('get_redis_minifeed faild, %s', str(sys.exc_info()))
        g_redis_minifeed = None
        return None
예제 #2
0
def get_redis_feed_content():
    global logger
    global g_redis_content

    if g_redis_content != None:
        return g_redis_content

    try:
        g_redis_content = libredis.libredis(conf.g_conf['redis_net_assist'],
                                            'feed_content')
        return g_redis_content
    except:
        logger.error('get_redis_content faild, %s', str(sys.exc_info()))
        g_redis_content = None
        return None
예제 #3
0
def get_redis_req_recommend():
    global logger
    global g_redis_req_recommend

    if g_redis_req_recommend != None:
        return g_redis_req_recommend

    try:
        g_redis_req_recommend = libredis.libredis(
            conf.g_conf['redis_net_assist'], 'req_recommend')
        return g_redis_req_recommend
    except:
        logger.error('get_redis_content faild, %s', str(sys.exc_info()))
        g_redis_req_recommend = None
        return None
예제 #4
0
if __name__ == '__main__':
    if len(sys.argv) < 4:
        print 'Please useage: cache_name [exist/get/set/del/LRange/LPush/LRem] key value!'
        exit()

    if sys.argv[1] == '' or sys.argv[2] == '' or sys.argv[3] == '':
        print 'Please useage: cache_name [exist/get/set/del/LRange/LPush/LRem] key value!'
        exit()

    cache_name = sys.argv[1]
    op = sys.argv[2]
    key = sys.argv[3]
    redis = None

    try:
        redis = libredis.libredis(conf.g_conf['redis_net_assist'], cache_name)
    except:
        print 'get cache [%s] faild, %s' % (cache_name, str(sys.exc_info()))
        redis = None
        exit()

    bt = time.time()
    if op.lower() == 'exist':
        ret = redis.Exists(key)
        print 'errno: ' + str(redis.GetLastErrNo())
        print 'result:' + str(ret)

    elif op.lower() == 'get':
        ret = redis.Get(key)
        print 'errno: ' + str(redis.GetLastErrNo())
        print 'result:' + str(ret)
예제 #5
0
if __name__ == "__main__":
    if len(sys.argv) < 4:
        print "Please useage: cache_name [exist/get/set/del/LRange/LPush/LRem] key value!"
        exit()

    if sys.argv[1] == "" or sys.argv[2] == "" or sys.argv[3] == "":
        print "Please useage: cache_name [exist/get/set/del/LRange/LPush/LRem] key value!"
        exit()

    cache_name = sys.argv[1]
    op = sys.argv[2]
    key = sys.argv[3]
    redis = None

    try:
        redis = libredis.libredis(conf.g_conf["redis_net_assist"], cache_name)
    except:
        print "get cache [%s] faild, %s" % (cache_name, str(sys.exc_info()))
        redis = None
        exit()

    bt = time.time()
    if op.lower() == "exist":
        ret = redis.Exists(key)
        print "errno: " + str(redis.GetLastErrNo())
        print "result:" + str(ret)

    elif op.lower() == "get":
        ret = redis.Get(key)
        print "errno: " + str(redis.GetLastErrNo())
        print "result:" + str(ret)