Esempio n. 1
0
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'],
    })
Esempio n. 2
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),
     }
Esempio n. 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),
     }
Esempio n. 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)
 def _hgetall(self):
     return self.db.redis().hgetall(API.ns_of('myhash'))
Esempio n. 6
0
 def _hgetall(self):
     return self.db.redis().hgetall(API.ns_of('myhash'))
Esempio n. 7
0
def cache_zset(ctrl, message):
    _name = message.get('db', 'default')
    API.redis(_name).zrem( API.ns_of( message['zset'] ), message['value'] ) 
Esempio n. 8
0
def cache_hash(ctrl, message):
    _name = message.get('db', 'default')
    API.redis(_name).hdel( API.ns_of( message['hash'] ), message['field'] ) 
Esempio n. 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)