Preventing race condition in cache handling with Redis