Does System.set write flash each time event the value it is the same?

Have you tried that function?
If it does what you want, just use it.

Otherwise you can read flash just as any other memory location.
Have a look at this