Ejemplo n.º 1
0
 def refresh(cls, flag=0, message=''):
     client = get_redis_client(settings.AD_CLICK)
     if flag:
         client.set(cls.FLAG_KEY, 1)
     else:
         client.delete(cls.FLAG_KEY)
     client.set(cls.TEXT_KEY, message)
Ejemplo n.º 2
0
class ConfigRefresh(object):
    FLAG_KEY = 'config_refresh_key'
    TEXT_KEY = 'config_refresh_text_key'
    CLIENT = get_redis_client(settings.SERVERS['master']['redis'])

    @classmethod
    def set_updated(cls):
        cls.CLIENT.delete(cls.FLAG_KEY)

    @classmethod
    def refresh(cls, flag, msg):
        if flag:
            cls.CLIENT.set(cls.FLAG_KEY, 1)
        else:
            cls.CLIENT.delete(cls.FLAG_KEY)
        cls.CLIENT.set(cls.TEXT_KEY, msg)

    @classmethod
    def check(cls):
        from gconfig import game_config

        refresh_flag = cls.CLIENT.get(cls.FLAG_KEY)
        all_config_version = game_config.ver_md5
        refresh_msg = cls.CLIENT.get(cls.TEXT_KEY) or ''
        refresh_msg = refresh_msg.decode('utf-8')

        return refresh_flag or 0, all_config_version, refresh_msg
 def run(self):
     """# run: docstring
     args:
         :    ---    arg
     returns:
         0    ---
     """
     r = get_redis_client('a')
     d = r.hgetall('models.public_city||PublicCity||h1||20002')
     print len(d)
     while 1:
         pass
Ejemplo n.º 4
0
 def set(cls, flag):
     client = get_redis_client(settings.AD_CLICK)
     if flag:
         client.set(cls.KEY, 1)
     else:
         client.delete(cls.KEY)
Ejemplo n.º 5
0
 def get(cls):
     client = get_redis_client(settings.AD_CLICK)
     return 1 if client.get(cls.KEY) else 0
Ejemplo n.º 6
0
 def set(cls, value):
     client = get_redis_client(settings.AD_CLICK)
     client.set(cls.KEY, value)
Ejemplo n.º 7
0
 def check(cls):
     client = get_redis_client(settings.AD_CLICK)
     v = client.get(cls.FLAG_KEY)
     text = client.get(cls.TEXT_KEY) or ''
     text = text.decode('utf-8')
     return (1, text) if v else (0, text)
Ejemplo n.º 8
0
 def reset(cls):
     client = get_redis_client(settings.AD_CLICK)
     client.delete(cls.FLAG_KEY)