示例#1
0
文件: QrCode.py 项目: drxbate/q2k
def regist_url(url,bites=8,hours=48):
    
    md5=utility.md5code(url)
    
    cinfo = dict(state=0,code="",url=url,expire=0)
    cinfo.update(RedisCli.hgetall("Q2k:Urls:%s"%md5))
    if cinfo["state"]=="0":
        if cinfo["code"]=="":
            while True:
                code = utility.generateCode(bites)
                if not exists(code):
                    break
                time.sleep(0.1)
            cinfo["code"]=code
         
    
        RedisCli.hset("Q2k:Codes", cinfo["code"],url)
        RedisCli.hset("Q2k:Urls:%s"%md5,"code",cinfo["code"])
        RedisCli.hset("Q2k:Urls:%s"%md5,"state",1)
    
    #默认将过期时间向后延期
    RedisCli.hset("Q2k:Urls:%s"%md5,"expire",time.time()+hours*60*60)
    return cinfo["code"]
    
示例#2
0
文件: Profile.py 项目: drxbate/M1
def updateHashTable(uid, name, key="", value="", **dict):
    tag = "profile:%s:%s" % (uid, name)
    if dict != None and len(dict) > 0:
        RedisCli.hmset(tag, dict)
    if name != None:
        RedisCli.hset(tag, key, value)
示例#3
0
文件: QrCode.py 项目: drxbate/q2k
def apply(url,bites,hours):
    md5=utility.md5code(url)
    RedisCli.hset("Q2k:Urls:%s"%md5,"state",0)
    RedisCli.rpush("Q2k:Queue:Apply",json.dumps(dict(url=url,bites=bites,hours=hours)))