Fixes NPE when a discarded document is persisted.
Merge pull request #1 from laserval/new-cache

Fixes NPE when a discarded document is persisted.