CupidDB


CupidClient


class pycupiddb.CupidClient(host, port)

Parameters:

  • host : string
  • port : integer

Example:

    from pycupiddb import CupidClient

              cupid_client = CupidClient(host='localhost', port=5995)
  

set(key, value, timeout=0.0)

Save the value data to CupidDB at the specified key

Parameters:

  • key : string
  • value : Any

    If the value is a pandas.DataFrame, integer, or float, the function saves the data in its native format. For all other data types, the data is saved in pickled format.

  • timeout : float default 0.0

    The timeout in seconds. A timeout of `0.0` means the value will be stored permanently, with no expiration.

Returns:

  • Return type: None

get(key, default=None)

Parameters:

  • key : string
  • default : Any default None

    In the case where the key cannot be found, the function will return the specified default value. If no default value is specified, it will return None.

Returns:

  • Return type: Any

    Returns the value at the specified key. If no data exists at the key, it returns None.


get_dataframe(key, columns=[], filter_operation='AND', filters=[], result_cache_timeout=0.0, compression_type='')

For more information about filters argument, please refer to the RowFilter class

Parameters:

  • key : string
  • columns : list[string] default []

    List of DataFrame columns to get from the server

  • filter_operation : string default 'AND'

    Operation to apply to the filters. Possible values are "AND" and "OR"

  • filters : list[RowFilter] default []

    A list of RowFilter objects used to select rows from the CupidDB server.

  • result_cache_timeout : float default 0.0

    Specify the timeout in seconds for caching the filtered result. This can speed up the get_dataframe command for subsequent requests when the filter logic remains the same.

  • compression_type : string default ''

    Specify the type of compression to use when sending data back to the client. This can reduce the size of data transferred over the network, though it may increase processing time slightly. The default value is '', which indicates no compression. Possible values are '', 'lz4', and 'zstd'.

Returns:

  • Return type: DataFrame or None

    Returns the DataFrame at the specified key. If no data exists at the key, it returns `None`.


touch(key, timeout)

Updates the expiration time of the specified key without modifying its data or resetting its time-to-live (TTL).

Parameters:

  • key : string
  • timeout : float

    Timeout in seconds

Returns:

  • Return type: boolean

    Returns `True` if the `touch` command succeeded. If no data exists at the specified key, it returns `False`.


ttl(key)

Check the remaining time-to-live (TTL) of a key. It tells you how many seconds are left before the key expires.

Parameters:

  • key : string

Returns:

  • Return type: float or None

    Returns the remaining time-to-live (TTL) in seconds. If no data exists at the specified key, it returns `None`.


incr(key, delta=1)

Increments the integer value stored at the specified key.

Parameters:

  • key : string
  • delta : int default 1

    Amount to increment by

Returns:

  • Return type: int

    Returns the updated value


incr_float(key, delta=1.0)

Increments the float value stored at the specified key.

Parameters:

  • key : string
  • delta : float default 1.0

    Amount to increment by

Returns:

  • Return type: float

    Returns the updated value


keys()

Lists all keys in the database.

Parameters:

    Returns:

    • Return type: list

      Returns the list of keys that exists in the database


    delete(key)

    Deletes the specified key and its associated value from the database.

    Parameters:

    • key : string

    Returns:

    • Return type: boolean

      Returns `True` if the `delete` command succeeded. If no data exists at the specified key, it returns `False`.


    delete_many(keys)

    Deletes the specified keys in the list along with their associated values from the database.

    Parameters:

    • keys : list[string]

    Returns:

    • Return type: int

      The number of keys deleted successfully

    CupidDB

    In-memory Key-Value Data Store