neko32 / service-template

akka-http-based micro service baseline
0 stars 0 forks source link

TANU-000004 Introduce cache for BIN result #4

Closed neko32 closed 3 years ago

neko32 commented 3 years ago

Overview

Currently Bin service doesn't have cache for the result. Bin service should use cache to reduce IO with external BIN info service. However, service should NOT disrupt its operation if data fetch from cache fails

TODO

Success Criteria

neko32 commented 3 years ago

test evidence - log

{"@timestamp":"2021-10-03T01:22:30.537-04:00","@version":"1","message":"received bin/45717360 request..","logger_name":"org.tanuneko.core.router.RestRouter","thread_name":"tanuapp_sample-akka.actor.default-dispatcher-8","level":"INFO","level_value":20000}
{"@timestamp":"2021-10-03T01:22:30.543-04:00","@version":"1","message":"bin - 45717360","logger_name":"org.tanuneko.ops.DefaultBinRetrievalOps","thread_name":"tanuapp_sample-akka.actor.default-dispatcher-8","level":"INFO","level_value":20000}
{"@timestamp":"2021-10-03T01:22:38.244-04:00","@version":"1","message":"received bin/45717360 request..","logger_name":"org.tanuneko.core.router.RestRouter","thread_name":"tanuapp_sample-akka.actor.default-dispatcher-8","level":"INFO","level_value":20000}
{"@timestamp":"2021-10-03T01:22:38.244-04:00","@version":"1","message":"bin - 45717360","logger_name":"org.tanuneko.ops.DefaultBinRetrievalOps","thread_name":"tanuapp_sample-akka.actor.default-dispatcher-8","level":"INFO","level_value":20000}
{"@timestamp":"2021-10-03T01:22:38.245-04:00","@version":"1","message":"BIN 45717360 was retrieved from redis cache","logger_name":"org.tanuneko.ops.DefaultBinRetrievalOps","thread_name":"tanuapp_sample-akka.actor.default-dispatcher-5","level":"INFO","level_value":20000}
neko32 commented 3 years ago

test evidence - redis get result

127.0.0.1:6379> get binsvc:bin:45717360
"{\"number\":{\"length\":16,\"luhn\":true},\"scheme\":\"visa\",\"type\":\"debit\",\"brand\":\"Visa/Dankort\",\"prepaid\":false,\"country\":{\"numeric\":\"208\",\"alpha2\":\"DK\",\"name\":\"Denmark\",\"emoji\":\"\xf0\x9f\x87\xa9\xf0\x9f\x87\xb0\",\"currency\":\"DKK\",\"latitude\":56,\"longitude\":10},\"bank\":{\"name\":\"Jyske Bank\",\"url\":\"www.jyskebank.dk\",\"phone\":\"+4589893300\",\"city\":\"Hj\xc3\xb8rring\"}}\n"
127.0.0.1:6379>