-
I didn't find it in the documentation, does TinyDB keep a full copy of the data in memory? Or is it all on disk, and you only read/write there? Sorry for the silly question, I found a project (much simpler), and it keeps the copy in memory and has synchronization to disk. And I think this approach makes operations faster?? This is the project: https://github.com/Diegiwg/mycro-db. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The default JSONStorage basically Reads and writes the entire file from disk. There is some buffering and optimisation built into Python and even at the os level, but for the sake of simplicity you can assume there's nothing in memory. The MemoryStorage keeps everything in memory, hence the name. But it doesn't sync to disk at all. There are other Storage options that implement it in different ways. BetterJSONStorage for example keeps a copy in memory along with some other optimisations. You can also take a look at the CachingMiddleware of TinyDB, this also read from memory. |
Beta Was this translation helpful? Give feedback.
The default JSONStorage basically Reads and writes the entire file from disk. There is some buffering and optimisation built into Python and even at the os level, but for the sake of simplicity you can assume there's nothing in memory.
The MemoryStorage keeps everything in memory, hence the name. But it doesn't sync to disk at all.
There are other Storage options that implement it in different ways. BetterJSONStorage for example keeps a copy in memory along with some other optimisations.
You can also take a look at the CachingMiddleware of TinyDB, this also read from memory.