예제 #1
0
def get_user_by_url(r, u):
    user = User.objects(url=u).first()
    raise gen.Return(user)
    user = yield cache.get(r, u)
    if user:
        logging.debug('cache hit for {}'.format(u))
        raise gen.Return(user)
    else:
        logging.debug('cache miss for {}'.format(u))
        user = User.objects(url=u).first()
        cache.send(r, user)
        raise gen.Return(user)
예제 #2
0
 def save(self, r=None):
     if r:
         cache.invalidate(r, self)
         cache.send(r, self)
     return super(User, self).save()