30 lines
488 B
Go
30 lines
488 B
Go
package app
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"code.tnxs.net/taxnexus/lib/api/geo/geo_models"
|
|
)
|
|
|
|
var placeCache = placeCacheType{
|
|
obj: map[string]*geo_models.Place{},
|
|
}
|
|
|
|
type placeCacheType struct {
|
|
sync.RWMutex
|
|
obj map[string]*geo_models.Place
|
|
}
|
|
|
|
func (m *placeCacheType) get(key string) (*geo_models.Place, bool) {
|
|
m.RLock()
|
|
defer m.RUnlock()
|
|
r, ok := m.obj[key]
|
|
return r, ok
|
|
}
|
|
|
|
func (m *placeCacheType) put(key string, obj *geo_models.Place) {
|
|
m.Lock()
|
|
defer m.Unlock()
|
|
m.obj[key] = obj
|
|
}
|