// Thread A
start_transaction();
update_mysql(); // External I/O
commit_transaction();
remove_redis_cache("key");
// Thread B
if (read_redis_cache("key", msg)) {
return msg;
}
msg = read_mysql(); // External I/O
update_redis_cache("key", msg);