package app

import (
	"sync"

	"code.tnxs.net/taxnexus/lib/api/ledger/ledger_models"
)

var accountingRuleCache = accountingRuleCacheType{
	obj: map[string]map[string]*ledger_models.AccountingRule{},
}

type accountingRuleCacheType struct {
	sync.RWMutex
	obj map[string]map[string]*ledger_models.AccountingRule
}

func (m *accountingRuleCacheType) get(accountID string) (map[string]*ledger_models.AccountingRule, bool) {
	m.RLock()
	defer m.RUnlock()
	r, ok := m.obj[accountID]
	return r, ok
}
func (m *accountingRuleCacheType) put(accountID string, rules map[string]*ledger_models.AccountingRule) {
	m.Lock()
	defer m.Unlock()
	m.obj[accountID] = rules
}
