
public final class O2QCache extends Object implements OReadCache
| Modifier and Type | Field and Description |
|---|---|
static String |
CACHE_STATE_FILE
File which contains stored state of disk cache after storage close.
|
static String |
CACHE_STATISTIC_FILE_EXTENSION
Extension for file which contains stored state of disk cache after storage close.
|
static int |
MIN_CACHE_SIZE
Minimum size of memory which may be allocated by cache (in pages).
|
| Constructor and Description |
|---|
O2QCache(long readCacheMaxMemory,
int pageSize,
boolean checkMinSize,
int percentOfPinnedPages,
boolean printCacheStatistics,
int cacheStatisticsInterval) |
| Modifier and Type | Method and Description |
|---|---|
long |
addFile(String fileName,
long fileId,
OWriteCache writeCache) |
long |
addFile(String fileName,
OWriteCache writeCache) |
OCacheEntry |
allocateNewPage(long fileId,
OWriteCache writeCache,
OLogSequenceNumber startLSN) |
void |
changeMaximumAmountOfMemory(long readCacheMaxMemory)
Changes amount of memory which may be used by given cache.
|
void |
clear() |
void |
closeFile(long fileId,
boolean flush,
OWriteCache writeCache) |
void |
closeStorage(OWriteCache writeCache)
Performs following steps:
If flag
OGlobalConfiguration.STORAGE_KEEP_DISK_CACHE_STATE is set to true saves state of all queues of
2Q cache into file CACHE_STATE_FILE.The only exception is pinned pages they need to pinned again.
Closes all files and flushes all data associated to them.
|
void |
deleteFile(long fileId,
OWriteCache writeCache) |
void |
deleteStorage(OWriteCache writeCache) |
long |
getUsedMemory() |
void |
loadCacheState(OWriteCache writeCache)
Loads state of 2Q cache queues stored during storage close
closeStorage(OWriteCache) back into memory if flag
OGlobalConfiguration.STORAGE_KEEP_DISK_CACHE_STATE is set to true. |
OCacheEntry |
loadForRead(long fileId,
long pageIndex,
boolean checkPinnedPages,
OWriteCache writeCache,
int pageCount,
boolean verifyChecksums) |
OCacheEntry |
loadForWrite(long fileId,
long pageIndex,
boolean checkPinnedPages,
OWriteCache writeCache,
int pageCount,
boolean verifyChecksums,
OLogSequenceNumber startLSN) |
void |
pinPage(OCacheEntry cacheEntry,
OWriteCache writeCache) |
void |
releaseFromRead(OCacheEntry cacheEntry,
OWriteCache writeCache) |
void |
releaseFromWrite(OCacheEntry cacheEntry,
OWriteCache writeCache) |
OCacheEntry |
silentLoadForRead(long fileId,
int pageIndex,
OWriteCache writeCache,
boolean verifyChecksums)
Loads page from the disk cache if it is already loaded otherwise loads it from disk but does
not put it the disk cache.
|
void |
storeCacheState(OWriteCache writeCache)
Stores state of queues of 2Q cache inside of
CACHE_STATE_FILE file if flag
OGlobalConfiguration.STORAGE_KEEP_DISK_CACHE_STATE is set to true. |
void |
truncateFile(long fileId,
OWriteCache writeCache) |
public static final int MIN_CACHE_SIZE
public static final String CACHE_STATE_FILE
public static final String CACHE_STATISTIC_FILE_EXTENSION
public O2QCache(long readCacheMaxMemory,
int pageSize,
boolean checkMinSize,
int percentOfPinnedPages,
boolean printCacheStatistics,
int cacheStatisticsInterval)
readCacheMaxMemory - Maximum amount of direct memory which can allocated by disk cache in bytes.pageSize - Cache page size in bytes.checkMinSize - If this flat is set size of cache may be MIN_CACHE_SIZE or bigger.percentOfPinnedPages - Maximum percent of pinned pages which may be hold by this cache.MAX_PERCENT_OF_PINED_PAGESpublic final long addFile(String fileName, OWriteCache writeCache) throws IOException
addFile in interface OReadCacheIOExceptionpublic OCacheEntry silentLoadForRead(long fileId, int pageIndex, OWriteCache writeCache, boolean verifyChecksums)
OReadCachesilentLoadForRead in interface OReadCachepublic final long addFile(String fileName, long fileId, OWriteCache writeCache) throws IOException
addFile in interface OReadCacheIOExceptionpublic final OCacheEntry loadForWrite(long fileId, long pageIndex, boolean checkPinnedPages, OWriteCache writeCache, int pageCount, boolean verifyChecksums, OLogSequenceNumber startLSN) throws IOException
loadForWrite in interface OReadCacheIOExceptionpublic final void releaseFromWrite(OCacheEntry cacheEntry, OWriteCache writeCache)
releaseFromWrite in interface OReadCachepublic final OCacheEntry loadForRead(long fileId, long pageIndex, boolean checkPinnedPages, OWriteCache writeCache, int pageCount, boolean verifyChecksums) throws IOException
loadForRead in interface OReadCacheIOExceptionpublic final void releaseFromRead(OCacheEntry cacheEntry, OWriteCache writeCache)
releaseFromRead in interface OReadCachepublic final void pinPage(OCacheEntry cacheEntry, OWriteCache writeCache)
pinPage in interface OReadCachepublic void changeMaximumAmountOfMemory(long readCacheMaxMemory)
throws IllegalStateException
changeMaximumAmountOfMemory in interface OReadCachereadCacheMaxMemory - New maximum size of cache in bytes.IllegalStateException - In case of new size of disk cache is too small to hold existing pinned pages.public final OCacheEntry allocateNewPage(long fileId, OWriteCache writeCache, OLogSequenceNumber startLSN) throws IOException
allocateNewPage in interface OReadCacheIOExceptionpublic final void clear()
clear in interface OReadCachepublic final void truncateFile(long fileId,
OWriteCache writeCache)
throws IOException
truncateFile in interface OReadCacheIOExceptionpublic final void closeFile(long fileId,
boolean flush,
OWriteCache writeCache)
closeFile in interface OReadCachepublic final void deleteFile(long fileId,
OWriteCache writeCache)
throws IOException
deleteFile in interface OReadCacheIOExceptionpublic final void closeStorage(OWriteCache writeCache) throws IOException
OGlobalConfiguration.STORAGE_KEEP_DISK_CACHE_STATE is set to true saves state of all queues of
2Q cache into file CACHE_STATE_FILE.The only exception is pinned pages they need to pinned again.closeStorage in interface OReadCachewriteCache - Write cache all files of which should be closed. In terms of cache write cache = storage.IOExceptionpublic final void loadCacheState(OWriteCache writeCache)
closeStorage(OWriteCache) back into memory if flag
OGlobalConfiguration.STORAGE_KEEP_DISK_CACHE_STATE is set to true.
If maximum size of cache was decreased cache state will not be restored.loadCacheState in interface OReadCachewriteCache - Write cache is used to load pages back into cache if needed.closeStorage(OWriteCache)public final void storeCacheState(OWriteCache writeCache)
CACHE_STATE_FILE file if flag
OGlobalConfiguration.STORAGE_KEEP_DISK_CACHE_STATE is set to true.
Following format is used to store queue state:
storeCacheState in interface OReadCachewriteCache - Write cache which manages files cache state of which is going to be stored.public final void deleteStorage(OWriteCache writeCache) throws IOException
deleteStorage in interface OReadCacheIOExceptionpublic final long getUsedMemory()
getUsedMemory in interface OReadCacheCopyright © 2009–2025 OrientDB. All rights reserved.