Implementing the caching mechanism
Applying custom AOP to @Repository
transactions must be used with caution because it might ruin the performance of the database CRUD transactions instead of improving them. All @Repository
and @Transactional
Spring components can be managed by built-in Spring aspects through generating a Pointcut such as execution(@org.springframework.transaction.annotation.Transactional * *(..))
. Adding more custom aspects will, however, bring degradation to the DAO layer's performance. Aside from managing null
values, @Repository
only needs a custom @Aspect
when caching large amounts of data records that are frequently accessed.
Object caching is one of the solutions that helps an application enhance its performance through storing into the memory all frequently accessed data from the database. Instead of incurring database READ
overhead, caching will allow only the execution of a query transaction when its data is not yet saved in the memory. This recipe will create a...