loopback-next
loopback-next copied to clipboard
Examples: Added new Redis Cache Example
Redis cache example uses loop-api-cache package. The example describes detailed steps for creating a cache. Firstly, you must create a cache model and a data source (Redis key-value connector) to connect with Redis. Then, implement a cache strategy provider. Here you can write custom logic for getting and setting cached values. In sequence, add a check to see if for a given request there is already a cached value present. If yes, you can just return the cached value instead of getting it from the database. Add @cache(60)on any controller method to add caching. Parameter for cache decorator is the TTL (time to live)value for cache in seconds.
Checklist
- [x] DCO (Developer Certificate of Origin) signed in all commits
- [x]
npm testpasses on your machine - [x] New tests added or existing tests modified to cover all changes
- [x] Code conforms with the style guide
- [x] API Documentation in code was updated
- [x] Documentation in /docs/site was updated
- [x] Affected artifact templates in
packages/cliwere updated - [x] Affected example projects in
examples/*were updated
Hi @raymondfeng, Hope you are doing well. can you please take a look at our PR when you have time?
Thank you.
Pull Request Test Coverage Report for Build 2070729644
- 0 of 0 changed or added relevant lines in 0 files are covered.
- No unchanged relevant lines lost coverage.
- Overall coverage decreased (-76.06%) to 0.0%
| Totals | |
|---|---|
| Change from base Build 2068694465: | -76.06% |
| Covered Lines: | 0 |
| Relevant Lines: | 0 |