Cortex Caching Prerequisites
Cortex Caching Prerequisites
To enabling caching, ensure your repository class meets the following prerequisites.
@Component Repositories
Most repositories use the @Component annotation. To enable request-scoped caching on repositories, ensure the following prerequisites are met:
- Ensure that your repository is located in package following the naming pattern: *.integration.epcommerce.repository, where * is any prefix. For example, com.elasticpath.rest.resource.integration.epcommerce.repository would be an appropriate package.
- Ensure that your repository's class name ends with RepositoryImpl. For example, CarsRepositoryImpl.
Cortex caches on runtime for @Component annotated repositories.
@Named Legacy Repositories
Legacy repositories using the @Named annotation require the steps described for @Component annotated repositories, as well as the following requirements:
If the package name does not start with com.elasticpath.rest, then the package name must be added to the <context:component-scan/> element in resources\OSGI-INF\blueprint\ext-applicationContext-repositories-integration.xml:
<context:component-scan base-package="my.pkg.with.custom.repos" scope-resolver="org.springframework.context.annotation.Jsr330ScopeMetadataResolver"/commerce-legacy/>
When adding multiple packages to <context:component-scan/>, the values should be comma separated:
<context:component-scan base-package="my.pkg.with.custom.repos,my.pkg.with.custom.repos2" scope-resolver="org.springframework.context.annotation.Jsr330ScopeMetadataResolver"/commerce-legacy/>
Cortex caches at load time for @Named annotated repositories.