func DumpNoteCache() { ticker := time.Tick(5 * time.Second) for range ticker { for _, note := range NoteIdCache { if log.Error(db.UpdateNote(*note)) { continue } } } }
func Note(n model.DbNote) { if oldNote, in := NoteIdCache[n.Id]; in { log.Error(db.UpdateNote(*oldNote)) } NoteIdCache[n.Id] = &n if _, in := NoteTopicCache[n.TopicId]; in { NoteTopicCache[n.TopicId][n.Id] = &n } else { NoteTopicCache[n.TopicId] = make(map[string]*model.DbNote) NoteTopicCache[n.TopicId][n.Id] = &n } }