I have this specific scenario:
- The user is sending me request which contains a URL to a file in my private repository.
- The server side catch this request and Download the file.
- The server making some calculation on the downloaded file.
- The server sending the results back to client.
I implemented this in the "Naive" way. Which mean, I downloading the file (step 2) for each request. In most cases, the user will send the same file. So, I thought about better approach: keep the downloaded file in short term "cache".
This mean, I will download the item once, and use this for every user request.
Now the question is, how to manage those files?
In "perfect world", I will use the downloaded file for up to 30 minutes. After this time, I won't use it any more. So, optional solutions are:
- Making a file system mechanism to handling files for short terms. Negative: Complex solution.
- Using temporary directory to do this job (e.g.
Path.GetTempFileName()
). Negative: What if the system will start to delete those files, in the middle of reading it?
So, it's seems that each solution has bad sides. What do you recommend?