Ejemplo n.º 1
0
func (s *MemcacheStats) publishItemsStats() {
	s.mu.Lock()
	defer s.mu.Unlock()
	s.items = make(map[string]map[string]int64)
	for _, key := range itemsMetrics {
		key := key // create local var to keep current key
		s.items[key] = make(map[string]int64)
		stats.Publish(s.cachePool.name+"MemcacheItems"+formatKey(key), stats.CountersFunc(func() map[string]int64 {
			s.mu.Lock()
			defer s.mu.Unlock()
			return copyMap(s.items[key])
		}))
	}
}
Ejemplo n.º 2
0
func (s *MemcacheStats) publishSlabsStats() {
	s.mu.Lock()
	defer s.mu.Unlock()
	s.slabs = make(map[string]map[string]int64)
	for key, isSingle := range slabsSingleMetrics {
		key := key
		s.slabs[key] = make(map[string]int64)
		if isSingle {
			stats.Publish(s.cachePool.name+"MemcacheSlabs"+formatKey(key), stats.IntFunc(func() int64 {
				s.mu.Lock()
				defer s.mu.Unlock()
				return s.slabs[key][""]
			}))
		} else {
			stats.Publish(s.cachePool.name+"MemcacheSlabs"+formatKey(key), stats.CountersFunc(func() map[string]int64 {
				s.mu.Lock()
				defer s.mu.Unlock()
				return copyMap(s.slabs[key])
			}))
		}
	}
}