   Cache system for vfs
  Hello!I am writing at the moment on some my filesystem code. The pysical file stuff is ready to use. Now i am wiriting on my Virtual File System.It works very nice, but it would be better to use a kind of cache system.Lets say i process block 2 of the file "test.txt" it may be good to read the block before and two blocks after block 2.So that Block 1, 2, 3, 4 is in cache. Then when i read the block 3, it is already in cache and i only must update cache.Will this gives me a little faster acees to the vfs?What do you think about my idea?Thanks, Christian 
  Does your VFS also load compressed data? In that case, I''d cache at a higher level. Let''s say you want to load a texture. You read in from your archive, process the file (strip header, convert pixel format, decompress(*)), and then it''s ready to use. It is this final data that you want to reuse later, not the actual bits in the archive.Most uses I can think of are either one-shot reads (read the entire file), or streaming (read the next 64 KB); anything else should be covered by memory-mapping. That simplifies the VFS greatly  I was thinking about a complex cache for each 64 KB block, but realized it is unnecessary. Unless anyone can point out something important not covered here..(*) Note: decompression from archive is almost free for large files, because you can inflate a block while reading the next asynchronously. It doesn''t make sense to save as PNG, however: that''s also LZ compressed, and you''d have to unpack again for no benefit, as archive and PNG compression ratios are similar.WRT the example you give: why should you read *behind* the data that the game asks for? Seeks are very expensive - you want to scan through your files sequentially. You should organize your archives so that files are laid out in the order they are accessed. In that case, it would be beneficial to cache the last block read from the archive, because files don''t start on even block boundaries in the archive.I am working on this ATM as well. Does anyone else have any experiences with this they could share? ;  In my VFS i want to use compression and cryption. If a file is crypted/compressed or not will be decided by it''s extension. For instace, i watn to use LZO on *.texture files.The idea to cache also the block before the actual readed one is not so good, so i will drop it.I will have an routine [void DecodeBlock(String File, size_t Blocknumber);], which processes an block of an file. So here it will be decpryped and enpressed.The DecodeBlock function will be used by an CPackedFile class [class NESSEIA_API CPackedFile : public IFile]to get access to a file in the archive.Also i want to make this:CPackedFile File;File.Open("Test.txt")When the open function is called, the cache for this file will be set up.I also have an class called CPhysicalFile which uses memory mapping and other stuff to access pysical files. 