Beispiel #1
0
def get_document_by_id(document_id):
    doc = None

    if util.use_redis_caching == "true":
        util.add_cache_query_count()
        txt = util.get_from_redis_cache("doc:" + document_id)
        if not txt:
            util.add_cache_compute_count()
            doc = solr_data.query_doc_by_id(document_id,
                                            solr_url=util.solr_url)
            util.write_to_redis_cache("doc:" + document_id, json.dumps(doc))
        else:
            doc = json.loads(txt)
    elif util.use_memory_caching == "true":
        util.add_cache_query_count()
        doc = _get_document_by_id(document_id)

    if not doc:
        return solr_data.query_doc_by_id(document_id, solr_url=util.solr_url)
    else:
        return doc
Beispiel #2
0
def _get_document_by_id(document_id):
    util.add_cache_compute_count()
    return solr_data.query_doc_by_id(document_id, solr_url=util.solr_url)