Class MetaStoreCacheInvalidator

java.lang.Object
com.axelor.meta.MetaStoreCacheInvalidator
All Implemented Interfaces:
PostDeleteEventListener, PostInsertEventListener, PostUpdateEventListener

public class MetaStoreCacheInvalidator extends Object implements PostInsertEventListener, PostUpdateEventListener, PostDeleteEventListener
Invalidates MetaStore JSON-field caches once per transaction that changes a cache-affecting entity.

When a transaction flushes its first cache-affecting entity, a single AfterTransactionCompletionProcess is registered and the remaining rows are deduplicated via PENDING. This avoids invalidating the (possibly distributed) cache for every row. This follows Hibernate's own CollectionCacheInvalidator, which registers its after-completion process from flush-time post events.

Changes to JSON fields and JSON models are only reflected by MetaStore once the transaction completes. A transaction that changes them and reads them back before committing may get the previously cached state.

The cache is invalidated on both commit and rollback: the cache loaders run on the caller's session, so a cache miss during a transaction with flushed changes may have cached uncommitted state.