package app

import (
	"sync"

	"code.tnxs.net/taxnexus/lib/api/geo/geo_models"
)

var coordinateCache = coordinateCacheType{
	obj: map[string]*geo_models.CoordinateBasic{},
}

type coordinateCacheType struct {
	sync.RWMutex
	obj map[string]*geo_models.CoordinateBasic
}

func (m *coordinateCacheType) get(addrStr string) (*geo_models.CoordinateBasic, bool) {
	m.RLock()
	defer m.RUnlock()
	r, ok := m.obj[addrStr]
	return r, ok
}

func (m *coordinateCacheType) put(accountID string, coord *geo_models.CoordinateBasic) {
	m.Lock()
	defer m.Unlock()
	m.obj[accountID] = coord
}
