I am using the FileSystemStore on LittleFs with QSPIF-BD and I am writing a circular-logger.
The circular-logger has i.e. 1000 entries and if the 1000th entry is written, the oldest entry will be overwritten. Works similar to a circular buffer:
Therefor I am asking if it is faster with the FileSystemStore to overwrite the content of a Key-Value-Pair (entry), or delete the oldest entry and write a new entry?
I already implemented this feature long ago based on file-pointer (FILE*), speed is ok, as long as it does not wrap around (overwrite).
To clarify how it works and what I want to do I added the documentation:
@brief The CyclicFile Class
This file defines the CyclicFile class which is basically a file with max entries.
If data is written beyond the max length, the write position will wrap around and
writing continues at the start of the file. The same will be done for reading.
Cyclic File will be seen as a normal file.
From File-Start to File-End, but this is an abstract view on it.
Therefore we have a real memory position and an abstract postion.
The abstract postion order depends on the last added and first (available) added entry.
Cyclic File example:
- MP = Memory Position
- AP = Abstract postion (Content)
- FS = File-Start Pointer
- FE = File-End Pointer
No Wrap Around
With Wrap Around
Cyclic File will be seen as: