class TransientDataStore extends Object implements DataStore
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.
| Modifier and Type | Field and Description |
|---|---|
protected RouterContext | _context_context. |
protected Log | _log_log. |
| Constructor and Description |
|---|
TransientDataStore(RouterContext ctx)TransientDataStore. |
| Modifier and Type | Method and Description |
|---|---|
int | countLeaseSets()Number of lease sets in the store. |
boolean | forcePut(Hash key,
DatabaseEntry data)Unconditionally store, bypass all newer/older checks. |
DatabaseEntry | get(Hash key)The entry for the key, or null if not found. |
DatabaseEntry | get(Hash key,
boolean persist)For PersistentDataStore only - don't use here. |
Collection<DatabaseEntry> | getEntries()All entries in the data store. |
Set<Hash> | getKeys()All keys stored in the data store. |
Set<Map.Entry<Hash,DatabaseEntry>> | getMapEntries()All map entries in the data store. |
boolean | isInitialized()Whether the data store is initialized. |
boolean | isKnown(Hash key)Whether the data store contains the key. |
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 and return the entry for the key. |
DatabaseEntry | remove(Hash key,
boolean persist)For PersistentDataStore only - don't use here. |
void | rescan()No-op - the in-memory store has no external state to rescan. |
int | size() |
void | stop()Clear the in-memory store. |
String | toString()Debug string listing all stored entries. |
protected final RouterContext _context
protected final Log _log
public TransientDataStore(RouterContext ctx)
public int countLeaseSets()
countLeaseSets in interface DataStorepublic boolean forcePut(Hash key, DatabaseEntry data)
public DatabaseEntry get(Hash key)
public DatabaseEntry get(Hash key, boolean persist)
get in interface DataStorekey - the hash key to look uppersist - if true, keep the entry in persistent storageUnsupportedOperationException - alwayspublic Collection<DatabaseEntry> getEntries()
DataStoregetEntries in interface DataStorepublic Set<Hash> getKeys()
DataStorepublic Set<Map.Entry<Hash,DatabaseEntry>> getMapEntries()
DataStoregetMapEntries in interface DataStorepublic boolean isInitialized()
isInitialized in interface DataStorepublic boolean isKnown(Hash key)
public boolean put(Hash key, DatabaseEntry data)
DataStorepublic boolean put(Hash key, DatabaseEntry data, boolean persist)
put in interface DataStorekey - the hash key to store underdata - the database entry to storepersist - if true, keep the entry in persistent storageUnsupportedOperationException - alwayspublic DatabaseEntry remove(Hash key)
public DatabaseEntry remove(Hash key, boolean persist)
remove in interface DataStorekey - the hash key to removepersist - if true, also remove from persistent storageUnsupportedOperationException - alwayspublic void rescan()