
public 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 |
MAX_PERCENT_OF_PINED_PAGES
Maximum percent of pinned pages which may be contained in this cache.
|
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) |
| 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,
boolean verifyChecksums) |
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() |
OCacheEntry |
load(long fileId,
long pageIndex,
boolean checkPinnedPages,
OWriteCache writeCache,
int pageCount,
boolean verifyChecksums) |
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. |
void |
pinPage(OCacheEntry cacheEntry) |
void |
release(OCacheEntry cacheEntry,
OWriteCache writeCache) |
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 MAX_PERCENT_OF_PINED_PAGES
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)
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 long addFile(String fileName, OWriteCache writeCache) throws IOException
addFile in interface OReadCacheIOExceptionpublic long addFile(String fileName, long fileId, OWriteCache writeCache) throws IOException
addFile in interface OReadCacheIOExceptionpublic void pinPage(OCacheEntry cacheEntry) throws IOException
pinPage in interface OReadCacheIOExceptionpublic void changeMaximumAmountOfMemory(long readCacheMaxMemory)
throws IllegalStateException
readCacheMaxMemory - 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 OCacheEntry load(long fileId, long pageIndex, boolean checkPinnedPages, OWriteCache writeCache, int pageCount, boolean verifyChecksums) throws IOException
load in interface OReadCacheIOExceptionpublic OCacheEntry allocateNewPage(long fileId, OWriteCache writeCache, boolean verifyChecksums) throws IOException
allocateNewPage in interface OReadCacheIOExceptionpublic void release(OCacheEntry cacheEntry, OWriteCache writeCache)
release in interface OReadCachepublic void clear()
clear in interface OReadCachepublic void truncateFile(long fileId,
OWriteCache writeCache)
throws IOException
truncateFile in interface OReadCacheIOExceptionpublic void closeFile(long fileId,
boolean flush,
OWriteCache writeCache)
throws IOException
closeFile in interface OReadCacheIOExceptionpublic void deleteFile(long fileId,
OWriteCache writeCache)
throws IOException
deleteFile in interface OReadCacheIOExceptionpublic 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 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 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 void deleteStorage(OWriteCache writeCache) throws IOException
deleteStorage in interface OReadCacheIOExceptionpublic long getUsedMemory()
getUsedMemory in interface OReadCacheCopyright © 2009–2025 OrientDB. All rights reserved.