145
Having direct access to the data significantly speeds up the application. This benefit
is most noticeable in situations where the program is only interested in a part of the
data stored in the database. In conventional approaches, this would require copying the
whole data in some buffer and returning it to the application. With pmemkv, we provide
the application a direct pointer, and the application reads only as much as it is needed.
To make the API fully functional with various engine types, a flexible pmemkv_config
structure was introduced. It stores engine configuration options and allows you to
tune its behavior. Every engine has documented all supported config parameters. The
pmemkv library was designed in a way that engines are pluggable and extendable
to support the developers own requirements. Developers are free to modify existing
engines or contribute new ones (https://github.com/pmem/pmemkv/blob/master/
CONTRIBUTING.md#engines).
Listing 9-1 shows a basic setup of the pmemkv_config structure using the native C
API. All the setup code is wrapped around the custom function, config_setup(), which
will be used in a phonebook example in the next section. You can see how error handling
is solved in pmemkv – all methods, except for pmemkv_close() and pmemkv_errormsg(),
return a status. We can obtain error message using the pmemkv_errormsg() function. A
complete list of return values can be found in pmemkv man page.
Figure 9-5. Applications directly accessing data in place using pmemkv
Chapter 9 pmemkv: a persistent in- memory key-value store
Having direct access to the data significantly speeds up the application. This benefit
is most noticeable in situations where the program is only interested in a part of the
data stored in the database. In conventional approaches, this would require copying the
whole data in some buffer and returning it to the application. With pmemkv, we provide
the application a direct pointer, and the application reads only as much as it is needed.
To make the API fully functional with various engine types, a flexible pmemkv_config
structure was introduced. It stores engine configuration options and allows you to
tune its behavior. Every engine has documented all supported config parameters. The
pmemkv library was designed in a way that engines are pluggable and extendable
to support the developers own requirements. Developers are free to modify existing
engines or contribute new ones (https://github.com/pmem/pmemkv/blob/master/
CONTRIBUTING.md#engines).
Listing 9-1 shows a basic setup of the pmemkv_config structure using the native C
API. All the setup code is wrapped around the custom function, config_setup(), which
will be used in a phonebook example in the next section. You can see how error handling
is solved in pmemkv – all methods, except for pmemkv_close() and pmemkv_errormsg(),
return a status. We can obtain error message using the pmemkv_errormsg() function. A
complete list of return values can be found in pmemkv man page.
Figure 9-5. Applications directly accessing data in place using pmemkv
Chapter 9 pmemkv: a persistent in- memory key-value store
