Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a part of #6718. It introduces the Simple Storage Component.
The reason to introduce this component: in #6718 I need persistent storage for the
last_processed_torrent_id
that is used byTagComponent
during rules processing.Normal Tribler's approach is either to store values in SQL or to store values in separate files.
Examples
The SQL approach includes:
tribler/src/tribler-core/tribler_core/components/metadata_store/db/orm_bindings/misc.py
Lines 5 to 13 in eed41c7
With actual data:
The file approach includes using a single file like
exitnode_cache.dat
to store a small amount of persistent data.Another example: sometimes Tribler uses the config file like persistent storage:
tribler/src/tribler-core/tribler_core/components/libtorrent/download_manager/download_manager.py
Line 271 in eed41c7
tribler/src/tribler-core/tribler_core/components/libtorrent/download_manager/download_manager.py
Line 906 in eed41c7
Solution
Instead of using multiple small files, or "config-like-a-storage" or SQL tables for nonSQL data, we can use the one single JSON storage which is more suitable for these needs.
Simple Storage
Simple Storage is object storage that stores data in JSON format and uses
pydantic
BaseModel
class for defining models.The writing procedure calls every 5 minutes as well as on shutdown.
Heavier alternatives: