Add basic persistence support

Signed-off-by: Kirill Enykeev <enykeev@gmail.com>