Exemple #1
0
//LoadRecords loads and returns record maps from the disk..
func (c *Cache) LoadRecords(kind int) record.Map {
	m, err := record.FromRecordDB(c.Datfile, kind)
	if err != nil {
		log.Print(err)
		return nil
	}
	return m
}
Exemple #2
0
//GetContents returns recstrs of cache.
//len(recstrs) is <=2.
//used in templates
func (c *Cache) GetContents() []string {
	m, err := record.FromRecordDB(c.Datfile, record.Alive)
	if err != nil {
		log.Print(err)
		return nil
	}
	contents := make([]string, 0, 2)
	for _, tt := range m {
		contents = append(contents, util.Escape(tt.Recstr()))
		if len(contents) > 2 {
			return contents
		}
	}
	return contents
}