Class AsyncReadCache
java.lang.Object
com.orientechnologies.orient.core.storage.cache.chm.AsyncReadCache
- All Implemented Interfaces:
OReadCache
Disk cache based on ConcurrentHashMap and eviction policy which is asynchronously processed by
handling set of events logged in lock free event buffer. This feature first was introduced in
Caffeine framework https://github.com/ben-manes/caffeine and in ConcurrentLinkedHashMap library
https://github.com/ben-manes/concurrentlinkedhashmap . The difference is that if consumption of
memory in cache is bigger than 1% disk cache is switched from asynchronous processing of stream
of events to synchronous processing. But that is true only for threads which cause loading of
additional pages from write cache to disk cache. Window TinyLFU policy is used as cache eviction
policy because it prevents usage of ghost entries and as result considerably decrease usage of
heap memory.
-
Field Summary
Fields inherited from interface com.orientechnologies.orient.core.storage.cache.OReadCache
MIN_CACHE_SIZE -
Constructor Summary
ConstructorsConstructorDescriptionAsyncReadCache(OByteBufferPool bufferPool, long maxCacheSizeInBytes, int pageSize, boolean trackHitRate) -
Method Summary
Modifier and TypeMethodDescriptionfinal longaddFile(String fileName, long fileId, OWriteCache writeCache) final longaddFile(String fileName, OWriteCache writeCache) final OCacheEntryallocateNewPage(long fileId, OWriteCache writeCache, OLogSequenceNumber startLSN) final voidchangeMaximumAmountOfMemory(long maxMemory) final voidclear()final voidcloseFile(long fileId, boolean flush, OWriteCache writeCache) final voidcloseStorage(OWriteCache writeCache) Closes all files inside of write cache and flushes all associated data.final voiddeleteFile(long fileId, OWriteCache writeCache) final voiddeleteStorage(OWriteCache writeCache) final longfinal OCacheEntryloadForRead(long fileId, long pageIndex, OWriteCache writeCache, boolean verifyChecksums) final OCacheEntryloadForWrite(long fileId, long pageIndex, OWriteCache writeCache, boolean verifyChecksums, OLogSequenceNumber startLSN) final voidreleaseFromRead(OCacheEntry cacheEntry) final voidreleaseFromWrite(OCacheEntry cacheEntry, OWriteCache writeCache, boolean changed) final OCacheEntrysilentLoadForRead(long extFileId, int pageIndex, OWriteCache writeCache, boolean verifyChecksums) final voidtruncateFile(long fileId, OWriteCache writeCache)
-
Constructor Details
-
AsyncReadCache
public AsyncReadCache(OByteBufferPool bufferPool, long maxCacheSizeInBytes, int pageSize, boolean trackHitRate)
-
-
Method Details
-
addFile
- Specified by:
addFilein interfaceOReadCache- Throws:
IOException
-
addFile
- Specified by:
addFilein interfaceOReadCache- Throws:
IOException
-
loadForWrite
public final OCacheEntry loadForWrite(long fileId, long pageIndex, OWriteCache writeCache, boolean verifyChecksums, OLogSequenceNumber startLSN) - Specified by:
loadForWritein interfaceOReadCache
-
loadForRead
public final OCacheEntry loadForRead(long fileId, long pageIndex, OWriteCache writeCache, boolean verifyChecksums) - Specified by:
loadForReadin interfaceOReadCache
-
silentLoadForRead
public final OCacheEntry silentLoadForRead(long extFileId, int pageIndex, OWriteCache writeCache, boolean verifyChecksums) - Specified by:
silentLoadForReadin interfaceOReadCache
-
changeMaximumAmountOfMemory
public final void changeMaximumAmountOfMemory(long maxMemory) - Specified by:
changeMaximumAmountOfMemoryin interfaceOReadCache
-
releaseFromRead
- Specified by:
releaseFromReadin interfaceOReadCache
-
releaseFromWrite
- Specified by:
releaseFromWritein interfaceOReadCache
-
allocateNewPage
public final OCacheEntry allocateNewPage(long fileId, OWriteCache writeCache, OLogSequenceNumber startLSN) throws IOException - Specified by:
allocateNewPagein interfaceOReadCache- Throws:
IOException
-
getUsedMemory
public final long getUsedMemory()- Specified by:
getUsedMemoryin interfaceOReadCache
-
clear
public final void clear()- Specified by:
clearin interfaceOReadCache
-
truncateFile
- Specified by:
truncateFilein interfaceOReadCache- Throws:
IOException
-
closeFile
- Specified by:
closeFilein interfaceOReadCache
-
deleteFile
- Specified by:
deleteFilein interfaceOReadCache- Throws:
IOException
-
deleteStorage
- Specified by:
deleteStoragein interfaceOReadCache- Throws:
IOException
-
closeStorage
Description copied from interface:OReadCacheCloses all files inside of write cache and flushes all associated data.- Specified by:
closeStoragein interfaceOReadCache- Parameters:
writeCache- Write cache to close.- Throws:
IOException
-