Hello everybody,
got a quick scenario that I would like input on. I want to write a small web server (like the cinchy server, nothing too fancy) and one of the features I would like to have is a file cache. That is, say 4 MB (arbitrary) that I would use to copy the most frequently downloaded files to and serving them from memory instead of disk all the time.

There are two options which I am considering:

1) VirtualAlloc a buffer, ReadFile to this buffer and keep track of all the files in the buffer in a table (along with file sizes and frequency of access)
2) MapViewOfFile for each file I decide to load so that each file can have it's own address in memory. Track the pointer and handles for the file mapping as well as frequency of use.

I would like to know which people think is faster (for file load times) and easier to maintain. Other things I will have to consider is when files are altered on disk and how memory is paged to disk

As usual, any and all input is appreciated.

Thanks

--Chorus
Posted on 2002-12-08 19:53:52 by chorus
not a good argument, but...
I would prefer the Alloc and ReadFile version. Very high level API functions, like file mappings often have a lot small drawbacks.
At first everything seem to be much easier, but later you will trap into one of the problems. Also if you need to make sometimes
later a modification or extension, lower level based solutions are much more flexible.
Posted on 2002-12-09 04:32:27 by beaster