polarity-integration-utils
    Preparing search index...

    Interface PolarityCache

    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
    // In your integration functions:
    async function doLookup(entities, options, context) {
    const cache = context?.cache;
    if (!cache) return generateFreshData();

    try {
    // Check integration cache first
    const cached = await cache.integration.get(`lookup_${entity.value}`);
    if (cached) return cached;

    // Generate and cache new data
    const result = await apiCall(entity);
    await cache.integration.set(`lookup_${entity.value}`, result, { ttl: 300 });
    return result;
    } catch (error) {
    console.error('Cache error:', error);
    return generateFreshData(); // Fallback
    }
    }
    interface PolarityCache {
        global: GlobalCache;
        integration: IntegrationCache;
        user: UserCache;
    }
    Index

    Properties

    global: GlobalCache

    Global cache operations - shared across all integrations and users

    integration: IntegrationCache

    Integration-scoped cache operations - shared across all users of a specific integration

    user: UserCache

    User-scoped cache operations - specific to individual users