Example #1
0
func (this *SafeHostMap) Init() {
	var hostMap map[string]int

	if g.Config().ExternalNodes == "" {
		m, err := db.QueryHosts()
		if err != nil {
			return
		}
		hostMap = m
	} else {
		m, err := enc.QueryHosts()
		if err != nil {
			return
		}
		hostMap = m
	}

	this.Lock()
	defer this.Unlock()
	this.M = hostMap
	debug := g.Config().Debug
	if debug {
		log.Printf("[DEBUG][CACHE] host.init : %v", this.M)
	}
}
Example #2
0
func (this *SafeHostMap) Init() {
	m, err := db.QueryHosts()
	if err != nil {
		return
	}

	this.Lock()
	defer this.Unlock()
	this.M = m
}