Class SqlJetPageCache
- java.lang.Object
-
- org.tmatesoft.sqljet.core.internal.pager.SqlJetPageCache
-
- All Implemented Interfaces:
ISqlJetPageCache
public class SqlJetPageCache extends java.lang.Object implements ISqlJetPageCache
A complete page cache is an instance of this structure.- Author:
- TMate Software Ltd., Sergey Scherbina (sergey.scherbina@gmail.com)
-
-
Field Summary
Fields Modifier and Type Field Description static int
PAGE_CACHE_SIZE_DEFAULT
static int
PAGE_CACHE_SIZE_MINIMUM
static java.lang.String
SQLJET_PAGE_CACHE_SIZE
System property name for cache size configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanAll()
Mark all dirty list pages as clean Make every page in the cache clean.void
clear()
Discard the contents of the cachevoid
clearSyncFlags()
Clear flags from pages of the page cachevoid
close()
Reset and close the cache objectvoid
drop(ISqlJetPage page)
Remove page from cache Drop a page from the cache.ISqlJetPage
fetch(int pgno, boolean createFlag)
Try to obtain a page from the cache.int
getCachesize()
Get the cache-size for the pager-cache.ISqlJetPage
getDirtyList()
Get a list of all dirty pages in the cache, sorted by page numberint
getPageCount()
Return the total number of pages stored in the cacheint
getRefCount()
Return the total number of outstanding page referencesvoid
iterate(ISqlJetPageCallback iter)
Iterate through all pages currently stored in the cache.void
makeClean(ISqlJetPage page)
Make sure the page is marked as clean.void
makeDirty(ISqlJetPage page)
Make sure the page is marked as dirty.void
move(ISqlJetPage page, int newPgno)
Change a page number.void
open(int szPage, boolean purgeable, ISqlJetPageCallback stress)
Create a new pager cache.void
release(ISqlJetPage page)
Dereference a page.void
setCacheSize(int mxPage)
Set the suggested cache-size for the pager-cache.void
setPageSize(int pageSize)
Modify the page-size after the cache has been created.void
truncate(int pgno)
Remove all pages with page numbers more than pageNumber.
-
-
-
Field Detail
-
SQLJET_PAGE_CACHE_SIZE
public static final java.lang.String SQLJET_PAGE_CACHE_SIZE
System property name for cache size configuration.- See Also:
- Constant Field Values
-
PAGE_CACHE_SIZE_DEFAULT
public static final int PAGE_CACHE_SIZE_DEFAULT
- See Also:
- Constant Field Values
-
PAGE_CACHE_SIZE_MINIMUM
public static final int PAGE_CACHE_SIZE_MINIMUM
- See Also:
- Constant Field Values
-
-
Method Detail
-
open
public void open(int szPage, boolean purgeable, ISqlJetPageCallback stress)
Description copied from interface:ISqlJetPageCache
Create a new pager cache. Under memory stress, invoke xStress to try to make pages clean. Only clean and unpinned pages can be reclaimed.- Specified by:
open
in interfaceISqlJetPageCache
- Parameters:
szPage
- Size of every pagepurgeable
- True if pages are on backing storestress
- Call to try to make pages clean
-
setPageSize
public void setPageSize(int pageSize)
Description copied from interface:ISqlJetPageCache
Modify the page-size after the cache has been created. Change the page size for PCache object. This can only happen when the cache is empty.- Specified by:
setPageSize
in interfaceISqlJetPageCache
-
fetch
public ISqlJetPage fetch(int pgno, boolean createFlag) throws SqlJetException
Description copied from interface:ISqlJetPageCache
Try to obtain a page from the cache.- Specified by:
fetch
in interfaceISqlJetPageCache
createFlag
- If true, create page if it does not exist already- Returns:
- Throws:
SqlJetException
-
release
public void release(ISqlJetPage page)
Description copied from interface:ISqlJetPageCache
Dereference a page. When the reference count reaches zero, move the page to the LRU list if it is clean. One release per successful fetch. Page is pinned until released. Reference counted.- Specified by:
release
in interfaceISqlJetPageCache
-
drop
public void drop(ISqlJetPage page)
Description copied from interface:ISqlJetPageCache
Remove page from cache Drop a page from the cache. There must be exactly one reference to the page. This function deletes that reference, so after it returns the page pointed to by p is invalid.- Specified by:
drop
in interfaceISqlJetPageCache
-
makeDirty
public void makeDirty(ISqlJetPage page)
Description copied from interface:ISqlJetPageCache
Make sure the page is marked as dirty. If it isn't dirty already, make it so.- Specified by:
makeDirty
in interfaceISqlJetPageCache
-
makeClean
public void makeClean(ISqlJetPage page)
Description copied from interface:ISqlJetPageCache
Make sure the page is marked as clean. If it isn't clean already, make it so.- Specified by:
makeClean
in interfaceISqlJetPageCache
-
cleanAll
public void cleanAll()
Description copied from interface:ISqlJetPageCache
Mark all dirty list pages as clean Make every page in the cache clean.- Specified by:
cleanAll
in interfaceISqlJetPageCache
-
clearSyncFlags
public void clearSyncFlags()
Description copied from interface:ISqlJetPageCache
Clear flags from pages of the page cache- Specified by:
clearSyncFlags
in interfaceISqlJetPageCache
-
move
public void move(ISqlJetPage page, int newPgno)
Description copied from interface:ISqlJetPageCache
Change a page number. Used by incr-vacuum. Change the page number of page p to newPgno. If newPgno is 0, then the page object is added to the clean-list and the PGHDR_REUSE_UNLIKELY flag set.- Specified by:
move
in interfaceISqlJetPageCache
-
truncate
public void truncate(int pgno)
Description copied from interface:ISqlJetPageCache
Remove all pages with page numbers more than pageNumber. Reset the cache if pageNumber==0 Drop every cache entry whose page number is greater than "pgno".- Specified by:
truncate
in interfaceISqlJetPageCache
-
close
public void close()
Description copied from interface:ISqlJetPageCache
Reset and close the cache object- Specified by:
close
in interfaceISqlJetPageCache
-
clear
public void clear()
Description copied from interface:ISqlJetPageCache
Discard the contents of the cache- Specified by:
clear
in interfaceISqlJetPageCache
-
getDirtyList
public ISqlJetPage getDirtyList()
Description copied from interface:ISqlJetPageCache
Get a list of all dirty pages in the cache, sorted by page number- Specified by:
getDirtyList
in interfaceISqlJetPageCache
- Returns:
-
getRefCount
public int getRefCount()
Description copied from interface:ISqlJetPageCache
Return the total number of outstanding page references- Specified by:
getRefCount
in interfaceISqlJetPageCache
-
getPageCount
public int getPageCount()
Description copied from interface:ISqlJetPageCache
Return the total number of pages stored in the cache- Specified by:
getPageCount
in interfaceISqlJetPageCache
-
getCachesize
public int getCachesize()
Description copied from interface:ISqlJetPageCache
Get the cache-size for the pager-cache.- Specified by:
getCachesize
in interfaceISqlJetPageCache
- Returns:
-
setCacheSize
public void setCacheSize(int mxPage)
Description copied from interface:ISqlJetPageCache
Set the suggested cache-size for the pager-cache. If no global maximum is configured, then the system attempts to limit the total number of pages cached by purgeable pager-caches to the sum of the suggested cache-sizes.- Specified by:
setCacheSize
in interfaceISqlJetPageCache
-
iterate
public void iterate(ISqlJetPageCallback iter) throws SqlJetException
Description copied from interface:ISqlJetPageCache
Iterate through all pages currently stored in the cache.- Specified by:
iterate
in interfaceISqlJetPageCache
- Throws:
SqlJetException
-
-