Shortcuts

LmdbBackend

class mmengine.fileio.LmdbBackend(db_path, readonly=True, lock=False, readahead=False, **kwargs)[源代码]

Lmdb storage backend.

参数:
  • db_path (str) – Lmdb database path.

  • readonly (bool) – Lmdb environment parameter. If True, disallow any write operations. Defaults to True.

  • lock (bool) – Lmdb environment parameter. If False, when concurrent access occurs, do not lock the database. Defaults to False.

  • readahead (bool) – Lmdb environment parameter. If False, disable the OS filesystem readahead mechanism, which may improve random read performance when a database is larger than RAM. Defaults to False.

  • **kwargs – Keyword arguments passed to lmdb.open.

db_path

Lmdb database path.

Type:

str

get(filepath)[源代码]

Get values according to the filepath.

参数:

filepath (str or Path) – Here, filepath is the lmdb key.

返回:

Expected bytes object.

返回类型:

bytes

示例

>>> backend = LmdbBackend('path/to/lmdb')
>>> backend.get('key')
b'hello world'