woc.tch

class TCHashDB:

Object representing a TokyoCabinet Hash table

TCHashDB(path: str, ro: bool = False)

Create a new TokyoCabinet hash table object.

Parameters
  • path: path to the database file
  • ro: if True, open in lock-free read-only mode; if False, lock and open in write mode (create if not exists)
Raises
  • OSError: if the database cannot be opened
def get(self, key: bytes) -> bytes:

Get a record.

Raises
  • KeyError: if the key is not found
  • OSError: if the operation fails
def put(self, key: bytes, value: bytes) -> None:

Upsert a record.

Raises
  • OSError: if the operation fails
def delete(self, key: bytes) -> None:

Delete a record from the database.

Raises
  • OSError: if the operation fails
def drop(self) -> None:

Delete all records in the database.

Raises
  • OSError: if the operation fails
def close(self) -> None:

Close the database.

Raises
  • OSError: if the operation fails
def optimize(self) -> None:

Optimize the database.

Raises
  • OSError: if the operation fails