Cache Management
Data Machine uses ability-level clearCache() methods to invalidate cached services when handlers, step types, or tools are dynamically registered.
Overview
Data Machine uses various internal caches to optimize performance for service discovery and tool resolution. These caches are typically static properties within their respective ability/tool classes and are invalidated directly via their clearCache() methods.
Centralized Invalidation
The system relies on WordPress actions to trigger cache clearing. When a new handler or step type is registered, the relevant caches should be cleared via the appropriate ability or tool class.
Invalidation Hooks
Cache invalidation is typically triggered after ecosystem registration actions, then performed via HandlerAbilities::clearCache(), AuthAbilities::clearCache(), StepTypeAbilities::clearCache(), and ToolManager::clearCache().
Migration Note (@since v0.11.7):
HandlerServiceandStepTypeServicehave been deleted and replaced byHandlerAbilitiesandStepTypeAbilities.
Cache Clearing Methods
Migration Note (@since v0.11.7): HandlerService and StepTypeService have been deleted and replaced by HandlerAbilities and StepTypeAbilities.
HandlerAbilities::clearCache()AuthAbilities::clearCache()StepTypeAbilities::clearCache()ToolManager::clearCache()PluginSettings::clearCache()
Site Context Caching
Migration Note (@since v0.11.7): HandlerService and StepTypeService have been deleted and replaced by HandlerAbilities and StepTypeAbilities.
- Cache Key:
datamachine_site_context_data(WordPress transient) - Automatic Invalidation: Hooks into
save_post,delete_post,create_term,update_option_blogname, etc. - Manual Invalidation:
SiteContext::clear_cache().
TanStack Query Caching
Call the static clearCache() methods on the relevant classes when registrations change:
Implementation Details
The SiteContext directive provides cached WordPress site metadata for AI context injection. This cache is separate from ability-level cache clearing and is automatically invalidated when posts, terms, users, or site settings change.
- HandlerAbilities:
$handlers_cache,$settings_cache,$config_fields_cache. - AuthAbilities: cached providers.
- StepTypeAbilities:
$cache. - ToolManager:
$resolved_cache. - HandlerDocumentation:
$cached_all_handlers,$cached_by_step_type,$cached_handler_slugs, and ability class instances.