示例#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 getHashTable(uid, name):
    tag = "profile:%s:%s" % (uid, name)
    return RedisCli.hgetall(tag)
示例#3
0
文件: QrCode.py 项目: drxbate/q2k
def get_code(url):
    md5=utility.md5code(url)
    data = RedisCli.hgetall("Q2k:Urls:%s"%md5)
    data["state"] = int(data["state"])
    return data