f88446fAvoid reinitializing DefaultPersistentDirectoryStores
Prior to this commit, adding a `CleanupAction` when building a `PersistentCache` using `CacheBuilder.withCleanup()` caused the used implementation class to be changed from `DefaultPersistentDirectoryStore` to `DefaultPersistentDirectoryCache`. The latter adds initialization logic and has a very strict check in place that verifies whether the lock file has been unlocked cleanly. If not, it will delete all files in the cache in order to reinitialize it. Since the mere addition of a cleanup action should not change such a fundamental behavior, this commit moves the cleanup logic to the `DefaultPersistentDirectoryStore` class and instantiates it when a cleanup action is configured but no initialization related properties. b5eae7bEnable incremental cache cleanup
Instead of computing the complete list of eligible files at once, SingleDepthFileFinder now returns an Iterable that creates an Iterator that will incrementally walk the file tree. In addition, the CleanupAction.clean() operation now takes a CountdownTimer and implementations periodically check whether the timer has expired. If so, the current cleanup will be aborted. DefaultPersistentDirectoryCache now uses a timeout of 20 seconds which is well below the file locking timeout of 60 seconds. The marker file (gc.properties) will only be updated if the complete cleanup was able to finish without expiring the timeout. |
![]() |