MCPcopy Index your code
hub / github.com/simstudioai/sim / cacheLimits

Function cacheLimits

apps/sim/lib/table/billing.ts:151–167  ·  view source on GitHub ↗
(workspaceId: string, limits: TablePlanLimits)

Source from the content-addressed store, hash-verified

149}
150
151function cacheLimits(workspaceId: string, limits: TablePlanLimits): void {
152 // Keep the Map bounded for a new key: sweep expired entries, then (if a burst of
153 // all-fresh entries still sits at the cap) evict oldest-inserted ones. Map iteration
154 // is insertion order, so the first key is the oldest. Net: size never exceeds the cap.
155 if (limitsCache.size >= LIMITS_CACHE_MAX_ENTRIES && !limitsCache.has(workspaceId)) {
156 const now = Date.now()
157 for (const [key, entry] of limitsCache) {
158 if (entry.expiresAt <= now) limitsCache.delete(key)
159 }
160 while (limitsCache.size >= LIMITS_CACHE_MAX_ENTRIES) {
161 const oldest = limitsCache.keys().next().value
162 if (oldest === undefined) break
163 limitsCache.delete(oldest)
164 }
165 }
166 limitsCache.set(workspaceId, { limits, expiresAt: Date.now() + LIMITS_CACHE_TTL_MS })
167}
168
169/**
170 * Thrown by {@link assertRowCapacity} when a write would exceed the workspace's

Callers 1

getWorkspaceTableLimitsFunction · 0.85

Calls 2

deleteMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected