\"There are only two hard problems in Computer Science: cache invalidation and naming things.\"
Phil Karlton
Is there a
If you're going to getData() every time you do the transform, then you've eliminated the entire benefit of the cache.
For your example, it seems like a solution would be for when you generate the transformed data, to also store the filename and last modified time of the file the data was generated from (you already stored this in whatever data structure was returned by getData(), so you just copy that record into the data structure returned by transformData()) and then when you call transformData() again, check the last modified time of the file.