Main cache interface providing hierarchical caching with three scopes
Cache Hierarchy:
Global: System-wide data shared across all integrations
Integration: Data shared among all users of a specific integration
User: User-specific data within an integration context
Best Practices:
Use appropriate TTL values to prevent stale data
Handle cache misses gracefully (operations may return null)
Wrap cache operations in try/catch blocks
Use descriptive keys that won't conflict with other data
Example
// In your integration functions: asyncfunctiondoLookup(entities, options, context) { constcache = context?.cache; if (!cache) returngenerateFreshData();
try { // Check integration cache first constcached = awaitcache.integration.get(`lookup_${entity.value}`); if (cached) returncached;
// Generate and cache new data constresult = awaitapiCall(entity); awaitcache.integration.set(`lookup_${entity.value}`, result, { ttl:300 }); returnresult; } catch (error) { console.error('Cache error:', error); returngenerateFreshData(); // Fallback } }
Main cache interface providing hierarchical caching with three scopes
Cache Hierarchy:
Best Practices:
Example