コード例 #1
0
ファイル: appiosinfo.py プロジェクト: led-os/game-center
def get_app_item(appid):
    """
    获取所有应用列表
    """
    app_list = None
    app_list_dict = None

    # 从缓存取
    cache_name = config.GLOBAL_SETTINGS["cache_prefix"] + "ios_app_list"
    ch = cache.Cache(config.GLOBAL_SETTINGS['redis'])
    app_list = ch.get(cache_name)

    if app_list:
        app_list_dict = json.loads(app_list)
    else:
        with db.MysqlConnection(config.GLOBAL_SETTINGS['db']) as con:

            # 参照项目整合部分
            sql = "SELECT * FROM appios_info limit 0,30"
            app_list_dict = con.query(sql)
            # 设置缓存
            ch.set(cache_name, json.dumps(app_list_dict))
            ch.expire(cache_name, 5 * 60)
    for item in app_list_dict:
        if item['AppID'] == int(appid):
            break
    raise tornado.gen.Return(item)
コード例 #2
0
ファイル: localappinfo.py プロジェクト: led-os/game-center
def get_app_item(appid):
    """
    获取所有应用列表
    """
    app_list = None
    app_list_dict = None

    # 从缓存取
    cache_name = config.GLOBAL_SETTINGS["cache_prefix"] + "local_app_list"
    ch = cache.Cache(config.GLOBAL_SETTINGS['redis'])
    app_list = ch.get(cache_name)

    if app_list:
        app_list_dict = json.loads(app_list)
    else:
        with db.MysqlConnection(config.GLOBAL_SETTINGS['db']) as con:

            # 参照项目整合部分
            sql = "SELECT prs.SiteID,prs.AppID,prs.SubwayPackUrl from v_pack_site_relation prs where AppID=%s"
            app_list_dict = con.query(sql,appid)
            # 设置缓存
            ch.set(cache_name, json.dumps(app_list_dict))
            ch.expire(cache_name, 5 * 60)
    for item in app_list_dict:
        if item['AppID'] == int(appid):
            break
    raise tornado.gen.Return(item)

# # 测试
# if __name__ == "__main__":
#      get_app_list()
#      get_app_item(2)
コード例 #3
0
 def get(self):
     try:
         cache_obj = cache.Cache(config.GLOBAL_SETTINGS['redis'])
         if cache_obj.ping():
             if len(cache_obj.keys('hPackList:*')) > 0:
                 self.write('0')
     except Exception, ex:
         self.write('ex=%s' % ex)
コード例 #4
0
ファイル: updateinfo.py プロジェクト: led-os/game-center
def get_update_info(scheme_id, pack_name, channel_name):
    """获取更新信息
    """
    cache_obj = cache.Cache(config.GLOBAL_SETTINGS['redis'])
    cache_name = 'hPackList:%s_%s_%s' % (scheme_id, pack_name, channel_name)
    update_info = cache_obj.hgetall(cache_name)
    if update_info is None or update_info == {}:
        cache_name = 'hPackList:%s_%s_%s' % (0, pack_name, channel_name)
        update_info = cache_obj.hgetall(cache_name)
    return update_info
コード例 #5
0
def get_scheme_id(comm_params):
    """获取方案Id
    """
    ei = comm_params['ei'] if 'ei' in comm_params else ''
    ai = comm_params['ai'] if 'ai' in comm_params else ''
    wm = comm_params.get('wm', '')

    # unique_id = ei + '|' + ai
    c = cache.Cache(config.GLOBAL_SETTINGS['redis'])

    # logger.GlobalLogger().info('debug: wm=' + wm)
    
    test_scheme_list = c.smembers("test_scheme")
    if wm in test_scheme_list:
        return 1  # 测试方案
    else:
        return 0
コード例 #6
0
ファイル: localappinfo.py プロジェクト: led-os/game-center
def get_app_list():
    """
    获取所有应用列表
    """
    app_list = None
    app_list_dict = None

    # 从缓存取
    cache_name = config.GLOBAL_SETTINGS["cache_prefix"] + "local_app_list"
    ch = cache.Cache(config.GLOBAL_SETTINGS['redis'])
    app_list = ch.get(cache_name)
    #app_list =None
    if app_list:
        app_list_dict = json.loads(app_list)
    else:
        with db.MysqlConnection(config.GLOBAL_SETTINGS['db']) as con:

            # 参照项目整合部分
            sql = "SELECT prs.SiteID,prs.AppID,prs.SubwayPackUrl from v_pack_site_relation prs;"
            app_list_dict = con.query(sql)
            # 设置缓存
            ch.set(cache_name, json.dumps(app_list_dict))
            ch.expire(cache_name, 5 * 60)
    raise tornado.gen.Return(app_list_dict)
コード例 #7
0
def get_redis_cache():
    """
        获取缓存对象
    """
    ch = cache.Cache(config.GLOBAL_SETTINGS['redis'])  # 引用缓存信息
    return ch