Expire files in local storage

I have a scenario where I need to pre-download assets (i.e. images, etc) and store them in local storage for offline use. But additionally, so we don't use up too many resources, have an expiration policy on each asset in which the asset would self-delete. I couldn't find any solutions in NuGet which enabled me to do this. I started looking at PCLStorage, which looks great by the way, but I don't seem to have a way to set an expiration policy on the files.

Does anybody know if a way to do this? If not, I guess I have to build the expiration policy myself. My first thought was to have a procedure which occasionally crawls the file system, looking for expired files, and cleaning them up as needed. To do this I thought to use 'last access time' on the files, but unfortunately PCLStorage doesn't surface any kind of access or write time capabilities on files. So I guess I could store these timestamps in SQLite, a sibling metadata file, or even make my own file header and put the timestamp at the top of the file.

Does anybody have any thoughts on the best way to solve this problem?


Best Answer


Sign In or Register to comment.