0
DominaTang created
I noticed that ABP 9 introduced "Entity Cache", if a an Entity has navigation properties, for example, a Product has a list of Orders. If I register Product for entity cache, when Order is changed or added to the product, would the cached product has latest orders list?
1 Answer(s)
-
0
- ABP’s Entity Cache caches one entity instance by its key, and it is automatically invalidated only when that same entity is updated or deleted (so it can be reloaded from the database on the next request).
- Therefore, if you cache
Productand later anOrderis added/updated/removed, the cachedProductentry is not automatically refreshed just because a related entity changed. You should assume the cachedProductmay have a stale navigation collection (e.g.,Product.Orders) until theProductcache entry is explicitly invalidated or theProductitself is updated/deleted. - Practical guidance:
- Prefer caching entities that are used mostly as read-only reference data (or that don’t depend on frequently-changing navigation graphs).
- If you need “Product with latest Orders” semantics, don’t rely on
Productentity cache for the navigation list; instead query Orders separately (or implement your own invalidation strategy whenOrderchanges, e.g., publish an event and remove the relatedProductcache entry).
(verified) https://abp.io/docs/latest/framework/infrastructure/entity-cache
This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.