mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-05 16:58:59 +00:00
Adding a touch of error handling in redis stories.
This commit is contained in:
parent
4aaa01ea24
commit
a1549aa290
2 changed files with 11 additions and 8 deletions
|
@ -1337,13 +1337,15 @@ class MStory(mongo.Document):
|
||||||
|
|
||||||
def sync_redis(self):
|
def sync_redis(self):
|
||||||
r = redis.Redis(connection_pool=settings.REDIS_STORY_POOL)
|
r = redis.Redis(connection_pool=settings.REDIS_STORY_POOL)
|
||||||
r.sadd('F:%s' % self.story_feed_id, self.id)
|
if self.id:
|
||||||
r.zadd('zF:%s' % self.story_feed_id, self.id, time.mktime(self.story_date.timetuple()))
|
r.sadd('F:%s' % self.story_feed_id, self.id)
|
||||||
|
r.zadd('zF:%s' % self.story_feed_id, self.id, time.mktime(self.story_date.timetuple()))
|
||||||
|
|
||||||
def remove_from_redis(self):
|
def remove_from_redis(self):
|
||||||
r = redis.Redis(connection_pool=settings.REDIS_STORY_POOL)
|
r = redis.Redis(connection_pool=settings.REDIS_STORY_POOL)
|
||||||
r.srem('F:%s' % self.story_feed_id, self.id)
|
if self.id:
|
||||||
r.zrem('zF:%s' % self.story_feed_id, self.id)
|
r.srem('F:%s' % self.story_feed_id, self.id)
|
||||||
|
r.zrem('zF:%s' % self.story_feed_id, self.id)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def sync_all_redis(cls, story_feed_id=None):
|
def sync_all_redis(cls, story_feed_id=None):
|
||||||
|
|
|
@ -757,7 +757,7 @@ class MSocialSubscription(mongo.Document):
|
||||||
if not ignore_user_stories:
|
if not ignore_user_stories:
|
||||||
r.delete(unread_stories_key)
|
r.delete(unread_stories_key)
|
||||||
|
|
||||||
return story_ids
|
return [story_id for story_id in story_ids if story_id]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def feed_stories(cls, user_id, feed_ids, offset=0, limit=6, order='newest', read_filter='all'):
|
def feed_stories(cls, user_id, feed_ids, offset=0, limit=6, order='newest', read_filter='all'):
|
||||||
|
@ -1246,9 +1246,10 @@ class MSharedStory(mongo.Document):
|
||||||
if not redis_conn:
|
if not redis_conn:
|
||||||
redis_conn = redis.Redis(connection_pool=settings.REDIS_STORY_POOL)
|
redis_conn = redis.Redis(connection_pool=settings.REDIS_STORY_POOL)
|
||||||
|
|
||||||
redis_conn.sadd('SF:%s' % self.user_id, self.story_db_id)
|
if self.story_db_id:
|
||||||
redis_conn.zadd('zSF:%s' % self.user_id, self.story_db_id,
|
redis_conn.sadd('SF:%s' % self.user_id, self.story_db_id)
|
||||||
time.mktime(self.shared_date.timetuple()))
|
redis_conn.zadd('zSF:%s' % self.user_id, self.story_db_id,
|
||||||
|
time.mktime(self.shared_date.timetuple()))
|
||||||
|
|
||||||
def remove_from_redis(self):
|
def remove_from_redis(self):
|
||||||
r = redis.Redis(connection_pool=settings.REDIS_POOL)
|
r = redis.Redis(connection_pool=settings.REDIS_POOL)
|
||||||
|
|
Loading…
Add table
Reference in a new issue