Esempio n. 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)
Esempio n. 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()
Esempio n. 3
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)