Esempio n. 1
0
func (b *BaseData) CleanData(t time.Time) {
	daysAgo20 := t.AddDate(0, 0, -20)
	err := db.Remove(DB, C_REQUEST, bson.M{"time": bson.M{"$lt": daysAgo20}})
	if err != nil && !strings.Contains(err.Error(), "not found") {
		log.Error(err)
	}
}
Esempio n. 2
0
func (m *TopicMgr) DoDelete(t time.Time) {
	m.lock.Lock()
	defer m.lock.Unlock()
	for _, topic := range m.DeleteTopics {
		if topic.NeedDelete.AddDate(0, 0, 2).Before(t) {
			db.Remove(DB, C_TOPIC, bson.M{"id": topic.ID})
		}
	}
}
Esempio n. 3
0
func (m *TopicMgr) ImmeDelTopic(topic *Topic) error {
	m.lock.Lock()
	defer m.lock.Unlock()
	err := db.Remove(DB, C_TOPIC, bson.M{"id": topic.ID})
	if err == nil {
		delete(m.DeleteTopics, topic.ID)
		topic = nil
	}
	return err
}