PMEMKV-PYTHON(1)
β¨ NAME β¨
pmemkv-python β yes bestie, it's the pmemkv-python 1.0 manual page, section 1, PMEMKV-PYTHON(1). We're doing this. π
π«Ά PMEMKV PACKAGE π«Ά
Python bindings for pmemkv. That's it, that's the vibe. π
pmemkv is a local/embedded key-value datastore optimized for persistent memory. Wanna read more? Go look at https://pmem.io/pmemkv. No cap.
π Submodules
π¦ pmemkv.pmemkv module
Python bindings for pmemkv. Yeah, again β but for real this time. π
π class pmemkv.pmemkv.Database(engine, config)
Bases: object
Okay so this is THE main Python pmemkv class β the main character, honestly. It hands you the functions to operate on data in the database. π
You can use this class dict-like, i.a. accessing and assigning data using []. If an error/exception gets thrown from any method, it will contain pmemkv's status and error message. Currently returned statuses are described in the libpmemkv manpage: https://pmem.io/pmemkv/master/manpages/libpmemkv.3.html#errors
Possible exceptions to be thrown in the Python binding are as follows:
ErrorUnknownErrorNotSupportedInvalidArgumentConfigParsingErrorConfigTypeErrorStoppedByCallbackWrongEngineNameTransactionScopeError
Not me listing every single one. π We keep them ALL. Periodt.
π __init__(engine, config)
Parameters
engine(str) β Name of the engine to work with.config(dict) β Dictionary with parameters specified for the engine. Required configuration parameters are dependent on particular engine. For more information on engine configuration please look into pmemkv man pages.
π count_above(key)
Returns the number of currently stored key/value pairs in the pmemkv datastore, whose keys are greater than the given key. Lowkey a vibe check for your data. β¨
Parameters
key(str) β Sets the lower bound for querying.
Returns
number β Number of key/value pairs in the datastore, whose keys are greater than the given key.
Return type
int
πΈ count_all()
Returns the number of currently stored key/value pairs in the pmemkv datastore. All of them. The whole squad. π«Ά
Returns
number β Total number of elements in the datastore.
Return type
int
π¦ count_below(key)
Returns the number of currently stored key/value pairs in the pmemkv datastore, whose keys are less than the given key.
Parameters
key(str) β Sets the upper bound for querying.
Returns
number β Number of key/value pairs in the datastore, whose keys are lower than the given key.
Return type
int
π count_between(key1, key2)
Returns the number of currently stored key/value pairs in the pmemkv datastore, whose keys are greater than the key1 and less than the key2. A little range moment. π₯
Parameters
key1(str) β Sets the lower bound for querying.key2(str) β Sets the upper bound for querying.
Returns
number β Number of key/value pairs in the datastore, between given keys.
Return type
int
π exists(key)
Verifies the presence of a key/value pair in the pmemkv datastore. Basically: does this even exist, bestie? π
Parameters
key(str) β key to query for.
Returns
exists β true if element with given key exists in the datastore, false if not.
Return type
bool
β get(key, func)
Executes callback function for the value for the given key.
Parameters
key(str) β key to query for.func(function (may be lambda)) β Function to be called for specified key/value pair. Value passed tofuncis read-only buffer and may be accessed bymemoryviewfunction. Callback function should accept one positional argument, which is value. Please notice, key is not passed to callback function. For more information please look into Buffer Protocol documentation.
Key is NOT passed to the callback. Read it again, bestie. π
π§ get_above(key, func)
Executes callback function for every key/value pair stored in the pmemkv datastore, whose keys are greater than the given key.
Parameters
key(str) β Sets the lower bound for querying.func(function (may be lambda)) β Function to be called for each specified key/value pair. Key and value passed tofuncare read-only buffers and may be accessed bymemoryviewfunction. Callback function should accept two positional arguments, which are key and value. For more information please look into Buffer Protocol documentation.
π get_all(func)
Executes callback function for every key/value pair stored in the pmemkv datastore. Every. Single. One. π
Parameters
func(function (may be lambda)) β Function to be called for each key/value pair in the datastore. Key and value passed tofuncare read-only buffers and may be accessed bymemoryviewfunction. Callback function should accept two positional arguments, which are key and value. For more information please look into Buffer Protocol documentation.
π¦ get_below(key, func)
Executes callback function for every key/value pair stored in the pmemkv datastore, whose keys are lower than the given key.
Parameters
key(str) β Sets the upper bound for querying.func(function (may be lambda)) β Function to be called for each specified key/value pair. Key and value passed tofuncare read-only buffers and may be accessed bymemoryviewfunction. Callback function should accept two positional arguments, which are key and value. For more information please look into Buffer Protocol documentation.
π
get_between(key1, key2, func)
Executes callback function for every key/value pair stored in the pmemkv datastore, whose keys are greater than the key1 and less than the key2.
Parameters
key1(str) β Sets the lower bound for querying.key2(str) β Sets the upper bound for querying.func(function (may be lambda)) β Function to be called for each specified key/value pair. Key and value passed tofuncare read-only buffers and may be accessed bymemoryviewfunction. Callback function should accept two positional arguments, which are key and value. For more information please look into Buffer Protocol documentation.
π get_keys(func)
Executes callback function for every key stored in the pmemkv datastore. Just the keys, no values, we're being minimal. β¨
Parameters
func(function (may be lambda)) β Function to be called for each key. Key passed tofuncis read-only buffer and may be accessed bymemoryviewfunction. Callback function should accept one positional argument, which is key. For more information please look into Buffer Protocol documentation.
π get_keys_above(key, func)
Executes callback function for every key stored in the pmemkv datastore, whose keys are greater than the given key.
Parameters
key(str or byte-like object) β Sets the lower bound for querying.func(function (may be lambda)) β Function to be called for each key above one specified inkeyparameter. Key passed tofuncis read-only buffer and may be accessed bymemoryviewfunction. Callback function should accept one positional argument, which is key. For more information please look into Buffer Protocol documentation.
π«§ get_keys_below(key, func)
Executes callback function for every key stored in the pmemkv datastore, whose keys are lower than the given key.
Parameters
key(str or byte-like object) β Sets the upper bound for querying.func(function (may be lambda)) β Function to be called for each key below one specified inkeyparameter. Key passed tofuncis read-only buffer and may be accessed bymemoryviewfunction. Callback function should accept one positional argument, which is key. For more information please look into Buffer Protocol documentation.
πΊ get_keys_between(key1, key2, func)
Executes callback function for every key stored in pmemkv datastore, whose keys are greater than the key1 and less than the key2.
Parameters
key1(str or byte-like object) β Sets the lower bound for querying.key2(str) β Sets the upper bound for querying.func(function (may be lambda)) β bestie, this is the lil function that gets called for every single key chilling betweenkey1andkey2π«. The key handed tofuncis a read-only buffer, and you can poke at it with thememoryviewfunction if you're feeling fancy. Your callback needs to accept one positional argument, which iskey. Want the full lore? Go look at the Buffer Protocol documentation π.
get_string(key) π
Gets you a copy (as a string, obviously) of the value for whatever key you hand it.
Iconic behaviour alert: the value that get_string() gives back is still accessible even after the element gets removed from the datastore. It said "I'm not leaving, you're leaving" π
.
Parameters
key(str) β the key you're querying for, babe.
Returns
valueβ a copy of the value associated with the given key.
Return type
stror byte-like object
put(key, value) β¨
Inserts the key/value pair into the pmemkv datastore. This method is so not picky β it accepts Unicode objects and bytes-like objects π«Ά. And just so you know, Unicode objects get stored using 'utf-8' encoding. No cap.
Parameters
key(str or byte-like object) β the record's key; the record will be put into the database under its name.value(str or byte-like object) β the data to be inserted into this new datastore record.
remove(key) π
Removes the key/value pair from the pmemkv datastore for the given key. Gone. Ghosted. Not in the group chat anymore.
Parameters
key(str) β the record's key to query for, to be removed.
Returns
removedβtrueif the element was removed,falseif the element didn't exist before removal (it was never there, sorry bestie π).
Return type
bool
stop() π
Stops the running engine. That's it. That's the whole vibe. Sit down, engine, your shift is over π
Oh and btw, a readme file can be found here π β go read it, it's giving helpful.
genindexmodindexsearch
π AUTHOR π
Intel Corporation
πΈ COPYRIGHT πΈ
2022, Intel Corporation
And that's a wrap on the whole page, bestie π«Ά This was version 1.0, dated Mar 17, 2022, and honestly? It ate. Go forth and build your datastore, you main character πβ¨
π¦ where this page comes from
- ubuntu jammy: python-pmemkv-doc 1.0-4build1 Β· BSD-3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms