import std.file; static void[] readProxy(string fn) { return std.file.read(fn); } enum FN = "test.txt"; auto cachedData = FileCache!readProxy(FN); std.file.write(FN, "One"); scope(exit) remove(FN); assert(cachedData == "One"); Thread.sleep(filesystemTimestampGranularity); std.file.write(FN, "Two"); assert(cachedData == "Two"); auto mtime = FN.timeLastModified(); version (OSX) {} else // setTimes does not work on macOS 10.15 ? { Thread.sleep(filesystemTimestampGranularity); std.file.write(FN, "Three"); FN.setTimes(mtime, mtime); assert(cachedData == "Two"); }