Cached IsPath

TanayLabUtilities.CachedIsPath Module

Speed up stat calls, avoiding going to the OS. This greatly speeds up operations when working with NFS data. It assumes that all relevant filesystem modification operations are done through the API here. External modifications can be supported by specifying a timeout, so that the actual filesystem will be queried eventually for fresh results.

TanayLabUtilities.CachedIsPath.report_modified! Function
report_modified!(path::AbstractString)::Nothing

Report that the specified file or directory was modified in some way, so delete all relevant cached data. This includes the list of files in the containing directory; if a directory is modified, all the cached data data for all its sub-directories is deleted as well.

TanayLabUtilities.CachedIsPath.IS_PATH_CACHE_TIMEOUT Constant

How long to hold on to ispath results before going back to the OS and asking for an updated result. This can be controlled by setting the TLU_IS_PATH_CACHE_TIMEOUT environment variable.

By default, this is set to a negative value, meaning we cache everything forever. This is fastest and works as long as the code using cached_ispath also invokes `report_modified! (for example, the Daf file system FilesDaf format does this). If the code is designed to deal with external modifications to the file system, it should contain additional calls to `report_modified! to force refreshing the cache.

If this is zero then cached_ispath ignores the cache and simply calls ispath . This is slow (especially when accessing network disks) but is "safest" as we will always return the correct answer regardless of anything. This is provided as a failsafe method for disabling the mechanism.

Otherwise this can be set to the number of seconds to hold cache entries for. A low value (a few seconds) will significantly improve performance while still allowing multiple processes to (eventually) react to external changes to the file system. This is provided for completeness.

Index