Ejemplo n.º 1
0
 def push_tweet_to_cache(cls, tweet):
     queryset = Tweet.objects.filter(
         user_id=tweet.user_id).order_by('-created_at')
     key = USER_TWEETS_PATTERN.format(user_id=tweet.user_id)
     RedisHelper.push_object(key, tweet, queryset)
 def push_newsfeed_to_cache(cls, newsfeed):
     queryset = NewsFeed.objects.filter(user_id=newsfeed.user_id).order_by('-created_at')
     key = USER_NEWSFEEDS_PATTERN.format(user_id=newsfeed.user_id)
     RedisHelper.push_object(key, newsfeed, queryset)
Ejemplo n.º 3
0
 def push_tweet_to_cache(cls, tweet):
     # Queryset is lazy loading
     # 此时并没有进行数据库的访问,只有需要进行iteration的时候才会真正查询数据库
     queryset = Tweet.objects.filter(user_id=tweet.user_id).order_by('-created_at')
     key = USER_TWEETS_PATTERN.format(user_id=tweet.user_id)
     RedisHelper.push_object(key, tweet, queryset)
Ejemplo n.º 4
0
 def push_tweet_to_cache(cls, tweet):
     key = USER_TWEETS_PATTERN.format(user_id=tweet.user_id)
     RedisHelper.push_object(key, tweet, lazy_load_tweets(tweet.user_id))
Ejemplo n.º 5
0
 def push_newsfeed_to_cache(cls, newsfeed):
     key = USER_NEWSFEEDS_PATTERN.format(user_id=newsfeed.user_id)
     RedisHelper.push_object(key, newsfeed,
                             lazy_load_newsfeeds(newsfeed.user_id))