예제 #1
0
파일: expired.py 프로젝트: bright-pan/ec2
def handler(ctrl, message):
    _name = message.get('db', 'default')
    _ns = API.ns_of( message['table'], message['pid'])
    
    src = API.db(_name)
    rs = src.select_from(message['table'], message['pid'])

    if  not rs: return -1
    
    if  not rs.get('queue',None)    or \
        not rs.get('timeout', None) or \
        not rs.get('cron_handler', None) or \
        not rs.get('retry', None):
        src.delete_from( message['table'], message['pid'] )
        return -2

    _retry = src.redis().hincrby( _ns , 'retry', -1)
    if  _retry<1 :
        src.delete_from( message['table'], message['pid'] )
        return -1

    API.expire(message, rs['timeout'])
    API.queue_push( rs['queue'], {
        'pid':      message['pid'],
        'table':    message['table'],
        'handler':  rs['cron_handler'],
    })
예제 #2
0
파일: cache.py 프로젝트: Big-Data/ec2
 def __init__(self, dbname, name, timeout):
     self._timeout = timeout
     self._dbname = dbname
     self._keyname = name
     self._redis = API.redis(self._dbname)
     self._ns = {
         'data':     API.ns_of(self._keyname),
     }
예제 #3
0
 def __init__(self, dbname, name, timeout):
     self._timeout = timeout
     self._dbname = dbname
     self._keyname = name
     self._redis = API.redis(self._dbname)
     self._ns = {
         'data': API.ns_of(self._keyname),
     }
예제 #4
0
    def testNs(self):
        rs = API.ns_of('a')
        tools.eq_('test:a', rs)

        rs = API.ns_of('a', 'b')
        tools.eq_('test:a:b', rs)
예제 #5
0
 def _hgetall(self):
     return self.db.redis().hgetall(API.ns_of('myhash'))
예제 #6
0
 def _hgetall(self):
     return self.db.redis().hgetall(API.ns_of('myhash'))
예제 #7
0
파일: expired.py 프로젝트: bright-pan/ec2
def cache_zset(ctrl, message):
    _name = message.get('db', 'default')
    API.redis(_name).zrem( API.ns_of( message['zset'] ), message['value'] ) 
예제 #8
0
파일: expired.py 프로젝트: bright-pan/ec2
def cache_hash(ctrl, message):
    _name = message.get('db', 'default')
    API.redis(_name).hdel( API.ns_of( message['hash'] ), message['field'] ) 
예제 #9
0
 def testNs(self):
     rs = API.ns_of('a')
     tools.eq_('test:a', rs) 
     
     rs = API.ns_of('a','b')
     tools.eq_('test:a:b', rs)