Persistence Manager πŸ˜•

2020-12-22
2020-12-28
  • andras-mozes - 2020-12-22

    Hello,

    I am a bit confused.
    I have set up successfully the Persistence Manager and it works fine.

    But...

    I would like to have 2 separate task: a producing one and a consuming one.
    The producing task is responsible for adding new values, while the consuming task would be responsible to read and delete this objects after sending it successfully to a MySQL server.

    I don't want to lose any of values read by producing task, this is the reason why I have set-up a persistence manager.

    Am I on the right path?

    Thanks for your help in advance.

    BR!

    P.S.: How would be possible to access/modify the values persisted from the other task?

     

    Last edit: andras-mozes 2020-12-22
  • dFx

    dFx - 2020-12-26

    So you are basically doing what mqtt broker does ?

    Persistent values are often stored in a file. File permissions are often locked for read only, explaining your troubles.

    To store values in a file that may be emptied by other thread, I would buffer some values in memory and write once the buffer is almost full.
    Then, as the file is no longer used, you may empty it.
    You can also empty your buffer on a trigger, in case of power loss for exemple.

    Third solution, a bit more complex, may be to reread the file stream every time you need to empty your buffer to it. This way, you can work both on emptying your buffer and the file, at the same time as writing in them. Be aware that the tasks should have same priorities, because if not, it may lead to duplicate data or data loss.

     
    πŸ‘
    1
  • Morberis

    Morberis - 2020-12-28

    If it helps here is a link to the documentation on the segmented buffer library.

     
    πŸ‘
    1

Log in to post a comment.