optimize #78 prevent many update pos in least time to expire index post cache

pull/78/head
alimy 3 years ago
parent abfee0621f
commit 88e1b6f417

@ -96,14 +96,19 @@ func (d *dataServant) startIndexPosts() {
} }
case <-d.expireIndexTick.C: case <-d.expireIndexTick.C:
logrus.Debugf("expire index posts by expireIndexTick") logrus.Debugf("expire index posts by expireIndexTick")
d.indexPosts = nil if len(d.indexPosts) != 0 {
d.atomicIndex.Store(d.indexPosts) d.indexPosts = nil
d.atomicIndex.Store(d.indexPosts)
}
case action := <-d.indexActionCh: case action := <-d.indexActionCh:
switch action { switch action {
case idxActCreatePost, idxActUpdatePost, idxActDeletePost, idxActStickPost: case idxActCreatePost, idxActUpdatePost, idxActDeletePost, idxActStickPost:
logrus.Debugf("remove index posts by action %s", action) logrus.Debugf("remove index posts by action %s", action)
d.indexPosts = nil // prevent many update post in least time
d.atomicIndex.Store(d.indexPosts) if len(d.indexPosts) != 0 {
d.indexPosts = nil
d.atomicIndex.Store(d.indexPosts)
}
default: default:
// nop // nop
} }

Loading…
Cancel
Save