DataReelDataReelC++ Toolkit Documentation

Page Cache (gxdPageCache)

Overview

gxdPageCache (gxdpcache.h, new in 6.3) caches 4 KB file pages for a gxDatabase (gxDatabase::EnablePageCache()) and holds the pages of open journal transactions. With use_map = 1 pages not in the cache are read from a read-only memory map of the file (off by default in 6.3, on by default in DataReel 7.3). Most programs use it through gxDatabase and gxdJournal.

Functions

gxdPageCache::gxdPageCache(gxdFPTR *f, FAU_t size, size_t max_bytes, int use_map = 0)

A cache of at most max_bytes for an open file of size bytes.

__ULWORD__ gxdPageCache::Read(void *buf, __ULWORD__ bytes, FAU_t address) / __ULWORD__ gxdPageCache::Write(const void *buf, __ULWORD__ bytes, FAU_t address)

Read or write through the cache. Returns the number of bytes moved.

void gxdPageCache::BeginTxn() / CommitTxn() / RollbackTxn() / int InTxn() const

Transaction support for gxdJournal: dirty pages become logged pages at commit; a rollback drops them.

int gxdPageCache::WriteLoggedPages() / void gxdPageCache::Clear()

Checkpoint: write the logged pages to the file; drop every page.

FAU_t FileSize() const / size_t MaxBytes() const / size_t CachedPages() const / size_t DirtyPages() const / size_t LoggedPages() const / int Mapped() const

Cache state.

See the 6.3 release notes and examples_database/journal.