Enable repeat responses to successful Lox requests
Closes #74
This MR stores Lox requests and their responses for a period of time in order to enable exact repeat responses. After a user has sent a Lox request, their connection could be interrupted, preventing them from receiving a response from the Lox authority. Prior to this change, this type of interruption would have resulted in the user being locked out of further interaction with Lox. This change stores each seen Lox request and its exact response for a brief period (MAX_STORAGE_DAYS
, currently set to 3 days) and returns the previously sent response if the same request is seen.
Alongside the HashMap
of Request, Responses, a Queue of Vec<String>
stores all of the requests seen in a day. When the day changes, the front entry is removed from the Queue and each of matching request, response pairs are removed from the hashmap as well.