public class CachingPageStorageWrapper extends CachingPageStorage
CachingPageStorage
.
This class is thread-safe; overlapped read/write and write/write
pairs may produce undefined data, but are otherwise safe.Modifier and Type | Class and Description |
---|---|
class |
CachingPageStorageWrapper.CachedPageImpl
A page which is currently in the cache.
|
CachingPageStorage.CachedPage
Constructor and Description |
---|
CachingPageStorageWrapper(PageStorage ps,
int cacheSize,
boolean asyncFlush)
An evicted page will be freed from memory (garbage
collected) if the user of this class has not retained a
reference to it; otherwise it simply no longer counts towards
the maximum cache size.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
close the PageStorage; invocation of any other methods after close() has undefined results
|
int |
createPage()
creates a new page with undefined contents; returns its pageid
|
void |
fsync(int pageid)
ensure that the designated page is written to nonvolatile storage
|
int |
getNumPages()
returns the number of pages; all pageids strictly less than this are valid
|
CachingPageStorage.CachedPage |
getPage(int pageid,
boolean readBytes)
Creates space in the cache for pageid, but only actually reads
the bytes if readBytes is true.
|
void |
readPage(int pageid,
byte[] buf,
int ofs)
reads a page
|
void |
setCacheSize(int cacheSize)
Sets the cache size, evicting pages if necessary.
|
void |
writePage(int pageid,
byte[] buf,
int ofs)
Write a page through the cache to nonvolatile storage
|
getPageSize
public CachingPageStorageWrapper(PageStorage ps, int cacheSize, boolean asyncFlush)
cacheSize
- the maximum number of NON-EVICTED pages in
the cache. Note that the total number of pages (evicted and
non-evicted) may exceed this number; this class simply ensures
that once a page is evicted its reference to the page is
weak. If the client application still holds a
reference to that page it will not be garbage collected.asyncFlush
- if true, a background thread will make a
best-effort attempt to flush dirty pages even before a flush()
is explicitly requested.public int createPage()
PageStorage
createPage
in class PageStorage
public int getNumPages()
PageStorage
getNumPages
in class PageStorage
public CachingPageStorage.CachedPage getPage(int pageid, boolean readBytes)
getPage
in class CachingPageStorage
public void writePage(int pageid, byte[] buf, int ofs)
CachingPageStorage
writePage
in class CachingPageStorage
public void readPage(int pageid, byte[] buf, int ofs)
PageStorage
readPage
in class PageStorage
public void setCacheSize(int cacheSize)
public void fsync(int pageid)
PageStorage
fsync
in class PageStorage
public void close()
PageStorage
close
in class PageStorage