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 |
protected Log |
_log |
| Constructor and Description |
|---|
TransientDataStore(RouterContext ctx) |
| 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() |
protected final RouterContext _context
protected final Log _log
public TransientDataStore(RouterContext ctx)
public int countLeaseSets()
DataStorecountLeaseSets in interface DataStorepublic boolean enableReverseLookups()
public boolean forcePut(Hash key, DatabaseEntry data)
public DatabaseEntry get(Hash key)
DataStorepublic 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()
getEntries in interface DataStorepublic Set<Hash> getKeys()
DataStorepublic Set<Map.Entry<Hash,DatabaseEntry>> getMapEntries()
getMapEntries in interface DataStorepublic boolean isInitialized()
DataStoreisInitialized in interface DataStorepublic boolean isKnown(Hash key)
DataStorepublic 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)
DataStorepublic 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()
DataStorepublic void stop()
DataStore