Saving context variable to the localfilesystem immediately on change

Yes I understand that the flush time can be configured. But my need is to preserve context data in case of sudden restart of the server.