Set the metadata provider this service should use. When unset, falls back to Metadata.Provider.
Use Clear.
Clear all cached entities Call when switching environments, users, or when needed
Clear cached entities for a specific conversation
The conversation ID
Use CreateConversation.
Create a new MJConversationEntity and automatically cache it The cache is the ONLY place GetEntityObject() should be called
User context
New MJConversationEntity instance (already cached)
Create a new MJConversationDetailEntity and automatically cache it The cache is the ONLY place GetEntityObject() should be called
User context
New MJConversationDetailEntity instance (already cached)
Get all cached ConversationDetail entities for a conversation (no DB call)
The conversation ID
Array of cached conversation details
Get all cached MJConversationEntity objects (no DB call)
Array of cached conversations
Use GetConversation.
Get a MJConversationEntity by ID from cache, or load it if not cached
The conversation ID
User context for loading
The cached or loaded MJConversationEntity, or null if not found
Get a MJConversationDetailEntity by ID from cache, or load it if not cached
The conversation detail ID
User context for loading
The cached or loaded MJConversationDetailEntity, or null if not found
Use GetStats.
Get cache statistics for debugging
Object with cache sizes
Optionalscope: ConversationScopeLoad the ConversationDetail entities of one scope of a conversation (Main, or one fork's path) that no rerun replaced, and cache them
The conversation ID
User context
Optionalscope: ConversationScopeThe rows to read; Main when omitted
Array of MJConversationDetailEntity objects
Refresh a specific cache by name This method can be extended to handle different cache types
The cache name ('Core', 'AI', 'Actions')
Refresh entity data by clearing cached entities of a specific type This forces a reload from the database on next access
The entity name to refresh (e.g., 'Conversations', 'MJ: Conversation Details')
Remove a MJConversationEntity from the cache
The conversation ID to remove
Remove a MJConversationDetailEntity from the cache
The conversation detail ID to remove
Global singleton cache for conversation-related entities. Maintains single instances of entities to prevent race conditions and ensure all components see the same object state.
Pattern: Instead of creating new entity instances with GetEntityObject() everywhere, request entities from this cache. The cache returns the same instance each time, so when one component updates entity.Status = 'Complete', all other components see that change immediately without needing to reload from the database.