I'm testing the waters with Arrow fx. My use case...
# arrow
j
I'm testing the waters with Arrow fx. My use case is a cache manager that loads from disk and saves itself periodically. I would expect to load (or create) the cache on startup with an error if the file could not be parsed. The periodic save interval would run on a background thread. I've not been able to find any examples or sample code of IO fx use in the context of a class or larger application. Is my approach reasonable? Are there better options?
s
What happens inside
load()
, or where does
hashCaches
ever get updated?
j
Load populates the map from a file on disk which contains hash values calculated on previous runs of the program. The remaining hashes are calculated lazily as needed so that I can get quick results. I'm looking for duplicate files, so unless I have two files with the same size, there's no reason to calculate the hash. Unfortunately this means the entire operation is sitting at the edge and cannot be considered pure. Once I do a pass through the analysis given a known set of files I can stop worrying about side-effects. If a file has its hash updated I would feed that back as a bulk operation by merging the ArchiveHashCache value. The question is should I have a snapshot (i.e. immutable) version of ArchiveHashCache to pass around between operations then accumulate and merge new hashes as above? Any good alternative? My current implementation has a FileReference data class with a lazy hash property that delegates to the cache and recalculates on the physical File on a cache miss.