
public interface OReadCache
Model of this cache is based on page model. All direct memory area is mapped to disk files and each file is split on pages. Page is smallest unit of work. The amount of RAM which can be used for data manipulation is limited so only a subset of data will be really loaded into RAM on demand, if there is not enough RAM to store all data, part of them will by flushed to the disk. If disk cache is closed all changes will be flushed to the disk.
Typical steps if you work with disk cache are following:
#openFile(String, OWriteCache) method#load(long, long, boolean, OWriteCache, int)OCacheEntry.getCachePointer()OCachePointer.acquireExclusiveLock()OCachePointer#getDataPointer()OCachePointer.releaseExclusiveLock()OCacheEntry.markDirty()release(OCacheEntry, OWriteCache)If you wish to read data, not change them, you use the same steps but:
OCachePointer.acquireSharedLock()
If you want to add new data but not to change existing one and you do not have enough space to add new data use method
#allocateNewPage(long, OWriteCache) instead of #load(long, long, boolean, OWriteCache, int).
#load(long, long, boolean, OWriteCache, int) method has checkPinnedPages parameter. Pinned pages are pages which are kept
always loaded in RAM ,this class of pages is needed for some data structures usually this attribute should be set to
false and it is set to true when storage goes through data restore procedure after system crash.
| 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 |
clear() |
void |
closeFile(long fileId,
boolean flush,
OWriteCache writeCache) |
void |
closeStorage(OWriteCache writeCache)
Closes all files inside of write cache and flushes all associated data.
|
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)
Load state of cache from file system if possible.
|
void |
pinPage(OCacheEntry cacheEntry) |
void |
release(OCacheEntry cacheEntry,
OWriteCache writeCache) |
void |
storeCacheState(OWriteCache writeCache)
Stores state of cache inside file if possible.
|
void |
truncateFile(long fileId,
OWriteCache writeCache) |
long addFile(String fileName, OWriteCache writeCache) throws IOException
IOExceptionlong addFile(String fileName, long fileId, OWriteCache writeCache) throws IOException
IOExceptionOCacheEntry load(long fileId, long pageIndex, boolean checkPinnedPages, OWriteCache writeCache, int pageCount, boolean verifyChecksums) throws IOException
IOExceptionvoid pinPage(OCacheEntry cacheEntry) throws IOException
IOExceptionOCacheEntry allocateNewPage(long fileId, OWriteCache writeCache, boolean verifyChecksums) throws IOException
IOExceptionvoid release(OCacheEntry cacheEntry, OWriteCache writeCache)
long getUsedMemory()
void clear()
void truncateFile(long fileId,
OWriteCache writeCache)
throws IOException
IOExceptionvoid closeFile(long fileId,
boolean flush,
OWriteCache writeCache)
throws IOException
IOExceptionvoid deleteFile(long fileId,
OWriteCache writeCache)
throws IOException
IOExceptionvoid deleteStorage(OWriteCache writeCache) throws IOException
IOExceptionvoid closeStorage(OWriteCache writeCache) throws IOException
writeCache - Write cache to close.IOExceptionvoid loadCacheState(OWriteCache writeCache)
writeCache - Write cache is used to load pages back into cache if possible.void storeCacheState(OWriteCache writeCache)
writeCache - Write cache which manages files cache state of which is going to be stored.Copyright © 2009–2025 OrientDB. All rights reserved.