Fix and cleanup format optimisation to be able to use % instead of optFormat
Add example with redis database