Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eiselems/update-cache-on-success
https://github.com/eiselems/update-cache-on-success
Last synced: 11 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/eiselems/update-cache-on-success
- Owner: eiselems
- License: mit
- Created: 2018-06-25T17:15:19.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-06-25T18:07:37.000Z (over 6 years ago)
- Last Synced: 2024-11-14T21:42:16.871Z (2 months ago)
- Language: Java
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# update-cache-on-success
This is a little showcase to see how cache eviction works together with refreshing a cache.
It relies on REDIS running on 127.0.0.1:6379 (default for local installation).
## The service
### How to run it
./mvnw spring-boot:run
or
./mvnw.bat spring-boot:run### What is it about?
After starting the service you can test it on http://localhost:8080/ e.g. [http://localhost:8080/eiselems](http://localhost:8080/eiselems).The service sadly has a high failure rate (Hey I KNOW, github is fine ...),
the error is introduced manually on this test service.
In 50% of the cases it throws a RunTimeException.Thankfully this service here is caching the response. The response is cached for 20 seconds.
What this should show:
* After successful retrieval it is stored for 20seconds
* After trying it again after more than 20 seconds the request is executed again
* When the cache is empty (nothing can be done here), or the cache expired (after more than 20s) the exception bubbles up until it reaches the controller (=> the user).Is there a way around so that instead of bubbling up the exception - that we can return the previous value?