net.i2p.router.networkdb.kademlia

## Class PersistentDataStore

- java.lang.Object
- - net.i2p.router.networkdb.kademlia.TransientDataStore
  - - net.i2p.router.networkdb.kademlia.PersistentDataStore

- All Implemented Interfaces:
    DataStore

       class PersistentDataStore
      extends TransientDataStore

  Write out keys to disk when we get them and periodically read ones we don't know about into memory, with newly read routers are also added to the routing table.

- - ### Field Summary

    - ### Fields inherited from class net.i2p.router.networkdb.kademlia.TransientDataStore

      `_context`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PersistentDataStore(RouterContext ctx, String dbDir, KademliaNetworkDatabaseFacade facade)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `DatabaseEntry` | `get(Hash key)`
    `DatabaseEntry` | `get(Hash key, boolean persist)` Prepare for having only a partial set in memory and the rest on disk
    `boolean` | `isInitialized()`
    `boolean` | `put(Hash key, DatabaseEntry data)`
    `boolean` | `put(Hash key, DatabaseEntry data, boolean persist)` for PersistentDataStore only - don't use here @throws IAE always
    `DatabaseEntry` | `remove(Hash key)`
    `DatabaseEntry` | `remove(Hash key, boolean persist)` for PersistentDataStore only - don't use here
    `void` | `rescan()`
    `void` | `restart()`
    `void` | `stop()`

    - ### Methods inherited from class net.i2p.router.networkdb.kademlia.TransientDataStore

      `countLeaseSets, getEntries, getKeys, getMapEntries, isKnown, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### PersistentDataStore

          public PersistentDataStore(RouterContext ctx,
                             String dbDir,
                             KademliaNetworkDatabaseFacade facade)
                              throws IOException

      Parameters:
        `dbDir` - relative path
      Throws:
        `IOException`

  - ### Method Detail

    - #### isInitialized

          public boolean isInitialized()

      Specified by:
        `isInitialized` in interface `DataStore`
      Overrides:
        `isInitialized` in class `TransientDataStore`

    - #### stop

          public void stop()

      Specified by:
        `stop` in interface `DataStore`
      Overrides:
        `stop` in class `TransientDataStore`

    - #### restart

          public void restart()

      Specified by:
        `restart` in interface `DataStore`
      Overrides:
        `restart` in class `TransientDataStore`

    - #### rescan

          public void rescan()

      Specified by:
        `rescan` in interface `DataStore`
      Overrides:
        `rescan` in class `TransientDataStore`

    - #### get

          public DatabaseEntry get(Hash key)

      Specified by:
        `get` in interface `DataStore`
      Overrides:
        `get` in class `TransientDataStore`

    - #### get

          public DatabaseEntry get(Hash key,
                          boolean persist)

      Prepare for having only a partial set in memory and the rest on disk
      Specified by:
        `get` in interface `DataStore`
      Overrides:
        `get` in class `TransientDataStore`
      Parameters:
        `persist` - if false, call super only, don't access disk

    - #### remove

          public DatabaseEntry remove(Hash key)

      Specified by:
        `remove` in interface `DataStore`
      Overrides:
        `remove` in class `TransientDataStore`

    - #### remove

          public DatabaseEntry remove(Hash key,
                             boolean persist)

      Description copied from class: `TransientDataStore`
      for PersistentDataStore only - don't use here
      Specified by:
        `remove` in interface `DataStore`
      Overrides:
        `remove` in class `TransientDataStore`

    - #### put

          public boolean put(Hash key,
                    DatabaseEntry data)

      Specified by:
        `put` in interface `DataStore`
      Overrides:
        `put` in class `TransientDataStore`
        `data` - must be validated before here
      Returns:
        success

    - #### put

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

      Description copied from class: `TransientDataStore`
      for PersistentDataStore only - don't use here @throws IAE always
      Specified by:
        `put` in interface `DataStore`
      Overrides:
        `put` in class `TransientDataStore`