remove CBLDocument from database document cache when purged

This is the fix to remove a purged document from the database cache that I submitted to the TouchDB-iOS project, including the fixes that you suggested in the old pull request.