예제 #1
0
 def RemoveExpiredItems(self):
     timenow=time.time()
     ThreeDaysAgo=time.time()-MU_MainConfig.THREEDAYS
     zset=r.zrangebyscore('expire',ThreeDaysAgo,timenow)
     hkeys=r.hkeys('queue')
     setofzset=set(zset)
     setofhkeys=set(hkeys)
     intersection=list(setofzset&setofhkeys)
     for i in range(len(hkeys)):
         if hkeys[i] not in intersection:
             title=r.hget('queue',hkeys[i])
             if hkeys[i] is MU_MainConfig.EDITEDPREFIX+title:
                 r.zrem('expire',MU_MainConfig.EDITEDPREFIX+title)
                 r.hdel('queue',hkeys[i])
                 name=r.hget('img',MU_MainConfig.EDITEDPREFIX+title)
                 os.remove('../imgcache/'+name)
                 r.hdel('img',MU_MainConfig.EDITEDPREFIX+title)
                 r.hdel('imgkey',MU_MainConfig.EDITEDPREFIX+title)
                 score=r.zscore('queuenumber',title)
                 r.zrem('queuenumber',title)
                 scorequeue=r.zrange('queuenumber',int(score)-1,-1)
                 for i in range(len(scorequeue)):
                     score=r.zscore('queuenumber',scorequeue[i])
                     r.zadd('queuenumber',scorequeue[i],score-1)
             else:
                 r.zrem('expire',MU_MainConfig.EDITEDPREFIX+title)
                 r.hdel('queue',hkeys[i])
예제 #2
0
def DeletePage(title):
    r.zrem('expire',MU_MainConfig.EDITEDPREFIX+title)
    r.hdel('queue',MU_MainConfig.EDITEDPREFIX+title)
    name=r.hget('img',MU_MainConfig.EDITEDPREFIX+title)
    os.remove('../imgcache/'+name)
    r.hdel('img',MU_MainConfig.EDITEDPREFIX+title)
    r.hdel('imgkey',title)
    score=r.zscore('queuenumber',title)
    r.zrem('queuenumber',title)
    scorequeue=r.zrange('queuenumber',int(score)-1,-1)
    for i in range(len(scorequeue)):
        score=r.zscore('queuenumber',scorequeue[i])
        r.zadd('queuenumber',scorequeue[i],score-1)
    return True
예제 #3
0
 def PostItem(self):
     Keys=r.zrange('queuenumber',0,-1)
     ReadyToPostItem=Keys[0]
     UnPushed=ForbiddenItemPushed(ReadyToPostItem)
     if UnPushed is not False:
         name=r.hget('img',MU_MainConfig.EDITEDPREFIX+ReadyToPostItem)
         post(ReadyToPostItem,name)
         r.hdel('queue',MU_MainConfig.EDITEDPREFIX+ReadyToPostItem)
         os.remove('../imgcache/'+name)
         r.hdel('img',MU_MainConfig.EDITEDPREFIX+ReadyToPostItem)
         r.hdel('imgkey',MU_MainConfig.EDITEDPREFIX+ReadyToPostItem)
         score=r.zscore('queuenumber',ReadyToPostItem)
         r.zrem('queuenumber',ReadyToPostItem)
         scorequeue=r.zrange('queuenumber',int(score)-1,-1)
         for i in range(len(scorequeue)):
             score=r.zscore('queuenumber',scorequeue[i])
             r.zadd('queuenumber',scorequeue[i],score-1)
         r.hset('queue',MU_MainConfig.PUSHEDPREFIX+ReadyToPostItem,ReadyToPostItem)
     else:
         pass
예제 #4
0
 def GetItemToSend(self):
     scorequeue=r.zrevrange('queuenumber',0,-1)
     try:
         lastnumber=r.zscore('queuenumber',scorequeue[0])
         for i in range(len(self.cache)):
             scorequeue=r.zrevrange('queuenumber',0,-1)
             lastnumber=r.zscore('queuenumber',scorequeue[0])
             ToBeSendTitle=r.hget('queue',MU_MainConfig.EDITEDPREFIX+self.cache[i])
             ToBeSendImage=r.hget('img',MU_MainConfig.EDITEDPREFIX+self.cache[i])
             if ToBeSendTitle not in scorequeue:
                 r.zadd('queuenumber',ToBeSendTitle,lastnumber)
                 r.zincrby('queuenumber',ToBeSendTitle,1)
             r.hset('imgkey',ToBeSendTitle,ToBeSendImage)
     except:
         for i in range(len(self.cache)):
             ToBeSendTitle=r.hget('queue',MU_MainConfig.EDITEDPREFIX+self.cache[i])
             ToBeSendImage=r.hget('img',MU_MainConfig.EDITEDPREFIX+self.cache[i])
             r.zadd('queuenumber',ToBeSendTitle,i)
             r.zincrby('queuenumber',ToBeSendTitle,1)
             r.hset('imgkey',ToBeSendTitle,ToBeSendImage)