|
Tkrzw
|
Page cache for buffering I/O operations. More...
#include <tkrzw_file_util.h>
Public Types | |
| typedef std::function< Status(int64_t off, void *buf, size_t size)> | ReadType |
| Type of callback function to read a clean buffer from the file. More... | |
| typedef std::function< Status(int64_t off, const void *buf, size_t size)> | WriteType |
| Type of callback function to write a dirty buffer to the file. More... | |
Public Member Functions | |
| PageCache (int64_t page_size, int64_t capacity, ReadType read_func, WriteType write_func) | |
| Constructor. More... | |
| ~PageCache () | |
| Destructor. More... | |
| Status | Read (int64_t off, void *buf, size_t size) |
| Reads data. More... | |
| Status | Write (int64_t off, const void *buf, size_t size) |
| Writes data. More... | |
| Status | Flush (int64_t off=0, int64_t size=0) |
| Flushes all dirty buffers to the file. More... | |
| void | Clear () |
| Clear all data. More... | |
| int64_t | GetRegionSize () |
| Gets the region size used for reading. More... | |
| void | SetRegionSize (int64_t size) |
| Sets the region size used for reading. More... | |
Static Public Attributes | |
| static constexpr int32_t | NUM_SLOTS = 16 |
| The number of slots for cuncurrency. More... | |
Page cache for buffering I/O operations.
| typedef std::function<Status(int64_t off, void* buf, size_t size)> tkrzw::PageCache::ReadType |
Type of callback function to read a clean buffer from the file.
| typedef std::function<Status(int64_t off, const void* buf, size_t size)> tkrzw::PageCache::WriteType |
Type of callback function to write a dirty buffer to the file.
| tkrzw::PageCache::PageCache | ( | int64_t | page_size, |
| int64_t | capacity, | ||
| ReadType | read_func, | ||
| WriteType | write_func | ||
| ) |
Constructor.
| page_size | The page size of the I/O operation. |
| capacity | The capacity of the cache by the number of pages. |
| read_func | The callback function to read a clean buffer from the file. |
| write_func | The callback function to write a dirty buffer to the file. |
| tkrzw::PageCache::~PageCache | ( | ) |
Destructor.
| Status tkrzw::PageCache::Read | ( | int64_t | off, |
| void * | buf, | ||
| size_t | size | ||
| ) |
Reads data.
| off | The offset of a source region. |
| buf | The pointer to the destination buffer. |
| size | The size of the data to be read. |
| Status tkrzw::PageCache::Write | ( | int64_t | off, |
| const void * | buf, | ||
| size_t | size | ||
| ) |
Writes data.
| off | The offset of the destination region. |
| buf | The pointer to the source buffer. |
| size | The size of the data to be written. |
| Status tkrzw::PageCache::Flush | ( | int64_t | off = 0, |
| int64_t | size = 0 |
||
| ) |
Flushes all dirty buffers to the file.
| off | The offset of the region to be synchronized. |
| size | The size of the region to be synchronized. If it is zero, the length to the end of file is specified. |
| void tkrzw::PageCache::Clear | ( | ) |
Clear all data.
Dirty buffers are not written back.
| int64_t tkrzw::PageCache::GetRegionSize | ( | ) |
Gets the region size used for reading.
| void tkrzw::PageCache::SetRegionSize | ( | int64_t | size | ) |
Sets the region size used for reading.
| size | The region size used for reading. |
|
staticconstexpr |
The number of slots for cuncurrency.