Add flag to cache storage to reduce number of disk accesses
This commit is contained in:
committed by
TeamCityServer
parent
395b2119a1
commit
f16b1c2d69
@@ -33,15 +33,19 @@ class CachingLazyStorage<K, V>(
|
|||||||
private val valueExternalizer: DataExternalizer<V>
|
private val valueExternalizer: DataExternalizer<V>
|
||||||
) : LazyStorage<K, V> {
|
) : LazyStorage<K, V> {
|
||||||
private var storage: PersistentHashMap<K, V>? = null
|
private var storage: PersistentHashMap<K, V>? = null
|
||||||
|
private var isStorageFileExist = true
|
||||||
|
|
||||||
private fun getStorageIfExists(): PersistentHashMap<K, V>? {
|
private fun getStorageIfExists(): PersistentHashMap<K, V>? {
|
||||||
if (storage != null) return storage
|
if (storage != null) return storage
|
||||||
|
|
||||||
|
if (!isStorageFileExist) return null
|
||||||
|
|
||||||
if (storageFile.exists()) {
|
if (storageFile.exists()) {
|
||||||
storage = createMap()
|
storage = createMap()
|
||||||
return storage
|
return storage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isStorageFileExist = false
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user