Add flag to cache storage to reduce number of disk accesses

This commit is contained in:
Aleksei.Cherepanov
2021-07-19 18:27:12 +03:00
committed by TeamCityServer
parent 395b2119a1
commit f16b1c2d69
@@ -33,15 +33,19 @@ class CachingLazyStorage<K, V>(
private val valueExternalizer: DataExternalizer<V>
) : LazyStorage<K, V> {
private var storage: PersistentHashMap<K, V>? = null
private var isStorageFileExist = true
private fun getStorageIfExists(): PersistentHashMap<K, V>? {
if (storage != null) return storage
if (!isStorageFileExist) return null
if (storageFile.exists()) {
storage = createMap()
return storage
}
isStorageFileExist = false
return null
}