net.i2p.router.networkdb.kademlia

## Interface DataStore

- All Known Implementing Classes:
    PersistentDataStore, TransientDataStore

      public interface DataStore

  Interface for database storage operations in the network database.

  Provides methods for storing, retrieving, and managing database entries including RouterInfo and LeaseSet objects with optional persistence control.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `countLeaseSets()` Count the number of LeaseSet entries in the store.
    `boolean` | `forcePut(Hash key, DatabaseEntry data)`
    `DatabaseEntry` | `get(Hash key)` Retrieve the database entry for the given key.
    `DatabaseEntry` | `get(Hash key, boolean persist)` Retrieve the database entry for the given key with optional persistence control.
    `Collection<DatabaseEntry>` | `getEntries()`
    `Set<Hash>` | `getKeys()` Get all keys stored in the data store.
    `Set<Map.Entry<Hash,DatabaseEntry>>` | `getMapEntries()`
    `boolean` | `isInitialized()` Check if the data store has been initialized.
    `boolean` | `isKnown(Hash key)` Check if the given key exists in the data store.
    `boolean` | `put(Hash key, DatabaseEntry data)` Store a database entry with the given key.
    `boolean` | `put(Hash key, DatabaseEntry data, boolean persist)` Store a database entry with the given key and persistence control.
    `DatabaseEntry` | `remove(Hash key)` Remove the entry for the given key.
    `DatabaseEntry` | `remove(Hash key, boolean persist)` Remove the entry for the given key with optional persistence control.
    `void` | `rescan()` Rescan the storage for any changes.
    `int` | `size()`
    `void` | `stop()` Stop the data store and release resources.

- - ### Method Detail

    - #### countLeaseSets

          int countLeaseSets()

      Count the number of LeaseSet entries in the store.
      Returns:
        the number of LeaseSets stored

    - #### forcePut

          boolean forcePut(Hash key,
                           DatabaseEntry data)

    - #### get

          DatabaseEntry get(Hash key)

      Retrieve the database entry for the given key.
      Parameters:
        `key` - the hash key to look up
      Returns:
        the database entry, or null if not found

    - #### get

          DatabaseEntry get(Hash key,
                            boolean persist)

      Retrieve the database entry for the given key with optional persistence control.
      Parameters:
        `key` - the hash key to look up
        `persist` - if true, keep the entry in persistent storage
      Returns:
        the database entry, or null if not found

    - #### getEntries

          Collection<DatabaseEntry> getEntries()

    - #### getKeys

          Set<Hash> getKeys()

      Get all keys stored in the data store.
      Returns:
        set of all hash keys

    - #### getMapEntries

          Set<Map.Entry<Hash,DatabaseEntry>> getMapEntries()

    - #### isInitialized

          boolean isInitialized()

      Check if the data store has been initialized.
      Returns:
        true if the store is ready for operations

    - #### isKnown

          boolean isKnown(Hash key)

      Check if the given key exists in the data store.
      Parameters:
        `key` - the hash key to look up
      Returns:
        true if the key is known and stored

    - #### put

          boolean put(Hash key,
                      DatabaseEntry data)

      Store a database entry with the given key.
      Parameters:
        `key` - the hash key to store under
        `data` - the database entry to store
      Returns:
        true if the store was successful

    - #### put

          boolean put(Hash key,
                      DatabaseEntry data,
                      boolean persist)

      Store a database entry with the given key and persistence control.
      Parameters:
        `key` - the hash key to store under
        `data` - the database entry to store
        `persist` - if true, keep the entry in persistent storage
      Returns:
        true if the store was successful

    - #### remove

          DatabaseEntry remove(Hash key)

      Remove the entry for the given key.
      Parameters:
        `key` - the hash key to remove
      Returns:
        the removed database entry, or null if not found

    - #### remove

          DatabaseEntry remove(Hash key,
                               boolean persist)

      Remove the entry for the given key with optional persistence control.
      Parameters:
        `key` - the hash key to remove
        `persist` - if true, also remove from persistent storage
      Returns:
        the removed database entry, or null if not found

    - #### rescan

          void rescan()

      Rescan the storage for any changes.

    - #### size

          int size()

      Returns:
        total size (RI and LS)

    - #### stop

          void stop()

      Stop the data store and release resources.