Caching
Caching improves performance by storing integration results and avoiding unnecessary re-execution. ToolJump automatically caches your integration results based on the cache property in your metadata.
note
For where and how result caching is implemented, see Server Architecture: caching.
note
This page describes result caching at the integration level. For caching arbitrary calls within your code, see Running code in an integration.
How Caching Works
When you set a cache value in your metadata, ToolJump will:
- Store results after the first execution
- Return cached results for subsequent requests within the cache period
- Re-execute the integration when the cache expires
Cache Configuration
metadata: {
name: 'my-integration',
cache: 300, // Cache for 5 minutes (300 seconds)
// ... other metadata
}
Advanced Caching
Custom Cache Keys
You can specify custom cache keys for more granular control:
metadata: {
name: 'user-profile',
cache: 3600,
match: {
contextType: 'github',
}
cacheKey: ['page.repository', 'page.section.name'], // Build key from context paths
// ... other metadata
}
Context-Aware Caching
Cache duration can vary based on context:
run: async function (context, secrets = {}, dataFiles = []) {
// Adjust cache based on context
let cacheDuration = 300; // Default 5 minutes
if (context.page?.repository === 'important-repo') {
cacheDuration = 60; // Cache for 1 minute on important repos
}
// Set cache duration dynamically
this.metadata.cache = cacheDuration;
// Your integration logic here
}
Debugging Caching
If caching isn't working as expected:
- Check cache duration: Is it set to 0?
- Verify context: Same context = same cache
- Check timestamps: Add logging to see execution frequency
- Force refresh: Temporarily disable caching or change the context
Next Steps
Now that you understand caching, learn about: