func (m *mongoStore) SaveTags(msg *common.SmapMessage) error { if msg == nil { return fmt.Errorf("Message is null") } // if the message has no metadata and is already in cache, then skip writing if !msg.HasMetadata() && m.uuidCache.Get(string(msg.UUID)) != nil { return nil } // save to the metadata database _, err := m.metadata.Upsert(bson.M{"uuid": msg.UUID}, bson.M{"$set": msg.ToBson()}) // and save to the uuid cache m.uuidCache.Set(string(msg.UUID), struct{}{}, m.cacheExpiry) if msg.Properties != nil && msg.Properties.UnitOfTime != 0 { m.uotCache.Set(string(msg.UUID), msg.Properties.UnitOfTime, m.cacheExpiry) } if msg.Properties != nil && msg.Properties.UnitOfMeasure != "" { m.uomCache.Set(string(msg.UUID), msg.Properties.UnitOfMeasure, m.cacheExpiry) } return err }