Pogreb has two options to synchronize the modification in memory to disk. Users can customize the interval duration. Then Pogreb will check automatically and do a synchronization between memory and database at the end of each period if there is any modification happen in this period. Users can also set the parameter to -1, then Pogreb will do a synchronization at every end of write, like Put() and Del(). Users can also call Sync() for a manual synchronization anytime to make the modification in the memory flush to the disk.
Pogreb supports API in GO. Users can open or create a database with Open(). Users can also add sync configuration as a parameter when open the database. It provides basic operations on database such as Put(), Get(), Has(), Delete(). Users can also iterate all the key/value pairs through Items() and Next(). The key and value for all the interfaces have to in the byte array form, and their length has to be within the max limit.
Pogreb supports multi-reader and one single writer. It uses a coarse grained lock for each operation. The lock is at the database level. Every read will try to fetch a RLock and release the lock when finish. And write will try to fetch a stronger lock to guanrantee the complete control over the entire database.
Pogreb uses the key/value store. There are no particular types for both key and value in Pogreb. It stores keys and values as byte array. In the example given by the document, it converts string to byte array as the key. Pogreb gives a max length limit on key and value. Key is no more than 2^16 bytes and value is no more than 2^31 bytes.
Pogreb is a disk-oriented database. All its files are persistently stored on the disk and it will write data into in memory file temporarily. The file in the disk will be mapped to virtual memory first by mmap on a Unix like system and CreateFileMapping on Windows. Users can specify the OS using or it will extract from the file system.
Pogreb uses N-ary storage model. There are two main level files for Pogreb is index file and data file. Index file stores the buckets as an array and each bucket is composed by the slot chain. Each slot stores the key information and the offset and size of value in the data file. Data file stores the key and value. Pogreb remain a free list to record the free space in the data file. It will search the free list to find a suitable block first when doing insertion. If there's no enough space for the new key-value pair, it will extend the data file.
Pogreb uses linear hash as the index. The hash function is by default, murmur32. Collision is solved by bucket chain which forms a linked list in the data file. The size of the whole hash table can represent as level L, so the total bucket number the hash table can hold is 2^L. Pogreb splits the buckets in the hash table when the items grow to a threshold(load factor) of the whole table size instead of rebuild the hash table. Pogreb uses 70% as the default load factor. It records the index of bucket to be splited as S and increment S during each split. When S grows up to the max number the hash table can hold, Pogreb will increase L and S will point to bucket 0 again to start a new round.
Pogreb is an embedded database. The database created by Pogreb is represented as files on disk. Users can access it through the custom API and there is no administrator.