Example #1
0
def update_sticky_thread_cache():
    threads = RedisList(STICKY_THREAD_CACHE_KEY)
    threads.delete()
    for x in [
            util.dumps((x.comment.id, x.text))
            for x in StickyThread.objects.all()
    ]:
        threads.rpush(x)
Example #2
0
    def update_scores(self):

        for algo in self.algorithms:
            ranking = algo.fun()
            temp_list = RedisList(gen_temp_key())

            if ranking:
                for comment in ranking:
                    temp_list.rpush(comment.id)

                # Atomically replace the frontpage with the new version.
                temp_list.rename(algo.frontpage.key)
            else:
                # If the ranking is empty, we just delete the frontpage key (the rename will fail)
                algo.frontpage.delete()
Example #3
0
 def __init__(self, fun):
     self.fun = fun
     self.name = fun.__name__
     self.frontpage = RedisList('frontpage:%s' % self.name)
Example #4
0
def get_sticky_threads_from_cache():
    """ Returns a list of comment ID / sticky text pairs. """
    threads = RedisList(STICKY_THREAD_CACHE_KEY)
    return [tuple(util.loads(thread)) for thread in threads.lrange(0, -1)]
def get_sticky_threads_from_cache():
    """ Returns a list of comment ID / sticky text pairs. """
    threads = RedisList(STICKY_THREAD_CACHE_KEY)
    return [tuple(util.loads(thread)) for thread in threads.lrange(0, -1)]
def update_sticky_thread_cache():
    threads = RedisList(STICKY_THREAD_CACHE_KEY)
    threads.delete()
    for x in [util.dumps((x.comment.id, x.text)) for x in StickyThread.objects.all()]:
        threads.rpush(x)