...
A cache is defined by three parameters: size, sector type allocation and mode. The size of the cache is the number of sectors that will fit into it at any time. Every sector is classified according to its type, either management, directory or file; the sector type allocation determines the percentage of the cache that will be devoted to each type. The mode determines when cache entries are created (i.e., when sectors are cached) and what happens upon write.
Choosing Cache Parameters
The following is an example using the cache for the volume “sdcard:0:”. The cache is used in write back mode, and the cache parameters are:
25% of cache size is used for management sector, 15% is used for directories sectors and the remaining (60%) is used for file sectors.
The application using μC/FS volume cache should vary the third and fourth parameters passed to FSVol_CacheAssign()
, and select the values that give the best performance.
For an efficient cache usage, it is better to do not allocate space in the cache for sectors of type file when the write size is greater than sector size.
When the cache is used in write back mode, all cache dirty sectors will be updated on the media storage only when the cache is flushed.