Exemple #1
0
def invalidate_doc(doc, deleted=False):
    """
    For a given doc, delete it and all reverses.

    return: (true|false existed or not)
    """
    #first by just individual doc
    doc_id = doc['_id']
    doc_key = key_doc_id(doc_id)

    # regardless if it exist or not, send it to the generational lookup and invalidate_all.
    prior_ver = rcache().get(doc_key, None)
    if prior_ver and not doc.get('doc_type', None):
        invalidate_doc = simplejson.loads(prior_ver)
    else:
        invalidate_doc = doc

    invalidate_doc_generation(invalidate_doc)
    rcache().delete(key_doc_id(doc_id))
    rcache().delete_pattern(key_doc_prop(doc_id, '*'))

    if not deleted and invalidate_doc.get('doc_id', None) in GenerationCache.doc_type_generation_map():
        do_cache_doc(doc)

    if prior_ver:
        return True
    else:
        return False