cache-entities
Installation
SKILL.md
Cache Entities with IEntityCache
IEntityCache<TEntityCacheItem, TKey> is ABP's higher-level abstraction on top of the distributed cache. Unlike a raw IDistributedCache<T> where you manage keys and invalidation yourself, an entity cache knows how to load an entity from its repository, cache it, and automatically invalidate the cached copy when the entity is updated or deleted — so the next call re-reads from the database and re-caches.
Source: https://github.com/abpframework/abp/blob/rel-10.5/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/IEntityCache.cs and https://github.com/abpframework/abp/blob/rel-10.5/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Caching/EntityCacheServiceCollectionExtensions.cs.
When to Use
- You repeatedly look up the same entity by id (e.g. a
Productreferenced from many places) and want caching without hand-writing cache keys or invalidation logic. - You want caching to invalidate itself automatically when the entity is updated or deleted.
- You want to cache a leaner DTO shape instead of the entity object.
- You need batched, cache-aware lookups by a set of ids.
When Not to Use
- General key/value caching where you manage the key yourself — use the distributed-caching-and-locking skill (
IDistributedCache<T>). - Distributed locking — use the distributed-caching-and-locking skill.
- Querying or persisting entities — use the ef-core-integration or mongodb-integration skills; the entity cache is read-only.