3.0.ipv8.dht.storage ==================== .. py:module:: 3.0.ipv8.dht.storage Classes ------- .. autoapisummary:: 3.0.ipv8.dht.storage.Value 3.0.ipv8.dht.storage.Storage Module Contents --------------- .. py:class:: Value(id_: bytes, data: bytes, max_age: float, version: int) Class for storing DHT values. .. py:attribute:: id .. py:attribute:: data .. py:attribute:: last_update .. py:attribute:: max_age .. py:attribute:: version .. py:property:: age :type: float The time (in seconds) since the last update. .. py:property:: expired :type: bool Whether the maximum time since the last update has been reached. .. py:method:: __eq__(other: object) -> bool Whether this value equals another given value. .. py:method:: __hash__() -> int The hash is always 0, forcing an expensive lookup. .. py:class:: Storage Class for storing key-value pairs in memory. .. py:attribute:: items :type: dict[bytes, list[Value]] .. py:method:: put(key: bytes, data: bytes, id_: bytes | None = None, max_age: float = 86400, version: int = 0) -> None Store the given data under a certain key. .. py:method:: get(key: bytes, starting_point: int = 0, limit: int | None = None) -> list[bytes] Get the values stored at the given key. .. py:method:: items_older_than(min_age: float) -> list[tuple[bytes, bytes]] Get all values that have not been updated for the given amount of time (in seconds). .. py:method:: clean() -> None Remove all expired items.