in-memory <-> db sync