Cache Invalidation — Is there a General Solution?

前端 未结 9 1381
情深已故
情深已故 2020-11-30 16:36

\"There are only two hard problems in Computer Science: cache invalidation and naming things.\"

Phil Karlton

Is there a

9条回答
  •  误落风尘
    2020-11-30 17:39

    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.

提交回复
热议问题