The current FileCacheDependency is based on lastModified timestamp of files. I’m not sure if this is sufficient. Files might change several times per second. While for some use cases it isn’t absolutely necessary to always display most recent data, it can be crucial for other use cases.

So instead of only checking the modified timestamp, also file size and CRC-checksum could be used to evaluate the dependency. CRC needs to read the file and thus is an expensive operation. But it should still be faster than reading and parsing a file (xml, ini, …), so using the cache should still provide a benefit.

Maybe provide a way to enable/ disable the different criteria one by one. Could be done by passing a flag field/ constants to the constructor.

Do you actually need this? Could you give an example of a use case? As an alternative one could use CExpressionDependency in combination with md5_file for example.

I recently ported a cgi to yii, that evaluates svn authorizations. Another cgi is responsible for writing the file (not yet ported). It might be called from client side in a batch operation, so it is likely that the autz file gets modified several times per second.

The file defines authorizations for some hundreds of users and repositories. The former cgi was written in c++ and handled the task in reasonable time, but parsing the file in php takes a few seconds, so I needed to cache the parsed data structure in memory.

My use case might be a bit special, considering that for most other jobs you can probably choose your preferred storage. On the other hand, I think the modified timestamp can become a problem whenever you decide to work with files, especially with files written by other programs or users. You simply can’t guarantee that the file does not change twice a second.