To add caching to a service or controller, just implement the ICachedService interface, adding a binding for the ICacheService and the applying the relevant decorators to the methods you want cached -
exportclassTestControllerimplementsICachedService{constructor(@repository(TestWithoutCachingRepository)publictestModelRepository:TestWithoutCachingRepository,@inject(CacheComponentBindings.CacheService)publiccache:ICacheService,){}cacheIdentifier='testRepo';@cacheInvalidator()@post('/tests')@response(200,{description:'Test model instance',content:{'application/json':{schema:getModelSchemaRef(Test)}},})asynccreate(@requestBody({content:{'application/json':{schema:getModelSchemaRef(Test,{title:'NewTest',exclude:['id'],}),},},})testModel:Omit<Test,'id'>,):Promise<Test>{returnthis.testModelRepository.create(testModel);}// ...@cachedItem()@get('/tests/count')@response(200,{description:'Test model count',content:{'application/json':{schema:CountSchema}},})asynccount(@param.where(Test)where?:Where<Test>):Promise<Count>{returnthis.testModelRepository.count(where);}/// ...