net.i2p.router.networkdb.kademlia

## Class TransientDataStore

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

- All Implemented Interfaces:
    DataStore
  Direct Known Subclasses:
    PersistentDataStore

      class TransientDataStore
      extends Object
      implements DataStore

  In-memory network database storage implementation.

  Provides volatile storage for database entries with no persistence to disk. Optimized for fast access and low memory footprint with concurrent operations using ConcurrentHashMap for thread-safe access patterns.

  Primarily used for client network databases and temporary storage during router operations where persistence is not required.

  Note: This should not be used for the main router database where persistence is necessary. Use PersistentDataStore instead.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected RouterContext` | `_context`
    `protected Log` | `_log`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TransientDataStore(RouterContext ctx)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `countLeaseSets()` Count the number of LeaseSet entries in the store.
    `boolean` | `enableReverseLookups()`
    `boolean` | `forcePut(Hash key, DatabaseEntry data)`
    `DatabaseEntry` | `get(Hash key)` Retrieve the database entry for the given key.
    `DatabaseEntry` | `get(Hash key, boolean persist)` for PersistentDataStore only - don't use here
    `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)` for PersistentDataStore only - don't use here
    `DatabaseEntry` | `remove(Hash key)` Remove the entry for the given key.
    `DatabaseEntry` | `remove(Hash key, boolean persist)` for PersistentDataStore only - don't use here
    `void` | `rescan()` Rescan the storage for any changes.
    `int` | `size()`
    `void` | `stop()` Stop the data store and release resources.
    `String` | `toString()`

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

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

- - ### Field Detail

    - #### _context

          protected final RouterContext _context

    - #### _log

          protected final Log _log

  - ### Constructor Detail

    - #### TransientDataStore

          public TransientDataStore(RouterContext ctx)

  - ### Method Detail

    - #### countLeaseSets

          public int countLeaseSets()

      Description copied from interface: `DataStore`
      Count the number of LeaseSet entries in the store.
      Specified by:
        `countLeaseSets` in interface `DataStore`
      Returns:
        the number of LeaseSets stored

    - #### enableReverseLookups

          public boolean enableReverseLookups()

    - #### forcePut

          public boolean forcePut(Hash key,
                                  DatabaseEntry data)

      Specified by:
        `forcePut` in interface `DataStore`

    - #### get

          public DatabaseEntry get(Hash key)

      Description copied from interface: `DataStore`
      Retrieve the database entry for the given key.
      Specified by:
        `get` in interface `DataStore`
      Parameters:
        `key` - the hash key to look up
      Returns:
        the database entry, or null if not found

    - #### get

          public DatabaseEntry get(Hash key,
                                   boolean persist)

      for PersistentDataStore only - don't use here
      Specified by:
        `get` in interface `DataStore`
      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
      Throws:
        `UnsupportedOperationException` - always

    - #### getEntries

          public Collection<DatabaseEntry> getEntries()

      Specified by:
        `getEntries` in interface `DataStore`
      Returns:
        Unmodifiable view, not a copy

    - #### getKeys

          public Set<Hash> getKeys()

      Description copied from interface: `DataStore`
      Get all keys stored in the data store.
      Specified by:
        `getKeys` in interface `DataStore`
      Returns:
        Unmodifiable view, not a copy

    - #### getMapEntries

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

      Specified by:
        `getMapEntries` in interface `DataStore`
      Returns:
        Unmodifiable view, not a copy

    - #### isInitialized

          public boolean isInitialized()

      Description copied from interface: `DataStore`
      Check if the data store has been initialized.
      Specified by:
        `isInitialized` in interface `DataStore`
      Returns:
        true if the store is ready for operations

    - #### isKnown

          public boolean isKnown(Hash key)

      Description copied from interface: `DataStore`
      Check if the given key exists in the data store.
      Specified by:
        `isKnown` in interface `DataStore`
      Parameters:
        `key` - the hash key to look up
      Returns:
        true if the key is known and stored

    - #### put

          public boolean put(Hash key,
                             DatabaseEntry data)

      Description copied from interface: `DataStore`
      Store a database entry with the given key.
      Specified by:
        `put` in interface `DataStore`
      Parameters:
        `data` - must be validated before here
        `key` - the hash key to store under
      Returns:
        success

    - #### put

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

      for PersistentDataStore only - don't use here
      Specified by:
        `put` in interface `DataStore`
      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
      Throws:
        `UnsupportedOperationException` - always

    - #### remove

          public DatabaseEntry remove(Hash key)

      Description copied from interface: `DataStore`
      Remove the entry for the given key.
      Specified by:
        `remove` in interface `DataStore`
      Parameters:
        `key` - the hash key to remove
      Returns:
        the removed database entry, or null if not found

    - #### remove

          public DatabaseEntry remove(Hash key,
                                      boolean persist)

      for PersistentDataStore only - don't use here
      Specified by:
        `remove` in interface `DataStore`
      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
      Throws:
        `UnsupportedOperationException` - always

    - #### rescan

          public void rescan()

      Description copied from interface: `DataStore`
      Rescan the storage for any changes.
      Specified by:
        `rescan` in interface `DataStore`

    - #### size

          public int size()

      Specified by:
        `size` in interface `DataStore`
      Returns:
        total size (RI and LS)

    - #### stop

          public void stop()

      Description copied from interface: `DataStore`
      Stop the data store and release resources.
      Specified by:
        `stop` in interface `DataStore`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`