PMEMKV-PYTHON(1)

πŸ“¦ version 1.0, in ubuntu jammy

✨ 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:

  • Error
  • UnknownError
  • NotSupported
  • InvalidArgument
  • ConfigParsingError
  • ConfigTypeError
  • StoppedByCallback
  • WrongEngineName
  • TransactionScopeError
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 to func is read-only buffer and may be accessed by memoryview function. 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 to func are read-only buffers and may be accessed by memoryview function. 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 to func are read-only buffers and may be accessed by memoryview function. 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 to func are read-only buffers and may be accessed by memoryview function. 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 to func are read-only buffers and may be accessed by memoryview function. 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 to func is read-only buffer and may be accessed by memoryview function. 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 in key parameter. Key passed to func is read-only buffer and may be accessed by memoryview function. 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 in key parameter. Key passed to func is read-only buffer and may be accessed by memoryview function. 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 between key1 and key2 πŸ’«. The key handed to func is a read-only buffer, and you can poke at it with the memoryview function if you're feeling fancy. Your callback needs to accept one positional argument, which is key. 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

  • str or 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 β€” true if the element was removed, false if 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.

  • genindex
  • modindex
  • search

πŸ‘‘ AUTHOR πŸ‘‘

Intel Corporation


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