DBEnforcer is the production Enforcer: reads account_limits + falls back to operator Defaults, counts current resources via the usage store, and caches the resolved Limits in-process for cacheTTL to keep hot paths off the DB on every send. The cache only stores the *Limits* (caps), not the *counts*
| 37 | // check; the win from caching limits is avoiding the join into |
| 38 | // account_limits, which is the costlier read. |
| 39 | type DBEnforcer struct { |
| 40 | store limitsReader |
| 41 | counter Counter |
| 42 | defaults Defaults |
| 43 | cacheTTL time.Duration |
| 44 | |
| 45 | mu sync.Mutex |
| 46 | cache map[string]cachedLimits |
| 47 | } |
| 48 | |
| 49 | type cachedLimits struct { |
| 50 | limits Limits |
nothing calls this directly
no outgoing calls
no test coverage detected