X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fzoom-record-cache.c;h=b999e59ce2166044e96edab4f64d55aac1eaac6a;hp=ea21312ce81b82c121442f40dca63f4b28585cf1;hb=ea0ffea1d02fe623b4da5b7b8aa972aa9f32f071;hpb=047d6669724619dd486a9bfa62cde1b909951491 diff --git a/src/zoom-record-cache.c b/src/zoom-record-cache.c index ea21312..b999e59 100644 --- a/src/zoom-record-cache.c +++ b/src/zoom-record-cache.c @@ -1,5 +1,5 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2013 Index Data + * Copyright (C) Index Data * See the file LICENSE for details. */ /** @@ -56,11 +56,13 @@ static size_t record_hash(int pos) return pos % RECORD_HASH_SIZE; } -void ZOOM_record_cache_add(ZOOM_resultset r, Z_NamePlusRecord *npr, - int pos, - const char *syntax, const char *elementSetName, - const char *schema, - Z_SRW_diagnostic *diag) +static ZOOM_record record_cache_add(ZOOM_resultset r, + Z_NamePlusRecord *npr, + int pos, + const char *syntax, + const char *elementSetName, + const char *schema, + Z_SRW_diagnostic *diag) { ZOOM_record_cache rc = 0; @@ -94,7 +96,9 @@ void ZOOM_record_cache_add(ZOOM_resultset r, Z_NamePlusRecord *npr, rc->pos = pos; rc->next = r->record_hash[record_hash(pos)]; r->record_hash[record_hash(pos)] = rc; + } + rc->rec.npr = npr; rc->rec.schema = odr_strdup_null(r->odr, schema); rc->rec.diag_set = 0; @@ -114,6 +118,17 @@ void ZOOM_record_cache_add(ZOOM_resultset r, Z_NamePlusRecord *npr, rc->rec.diag_message = odr_strdup_null(r->odr, diag->message); rc->rec.diag_details = odr_strdup_null(r->odr, diag->details); } + return &rc->rec; +} + +void ZOOM_record_cache_add(ZOOM_resultset r, Z_NamePlusRecord *npr, + int pos, + const char *syntax, const char *elementSetName, + const char *schema, + Z_SRW_diagnostic *diag) +{ + record_cache_add(r, npr, pos, syntax, elementSetName, schema, diag); + ZOOM_memcached_add(r, npr, pos, syntax, elementSetName, schema, diag); } ZOOM_record ZOOM_record_cache_lookup(ZOOM_resultset r, int pos, @@ -122,6 +137,7 @@ ZOOM_record ZOOM_record_cache_lookup(ZOOM_resultset r, int pos, const char *schema) { ZOOM_record_cache rc; + Z_NamePlusRecord *npr; for (rc = r->record_hash[record_hash(pos)]; rc; rc = rc->next) { @@ -136,6 +152,10 @@ ZOOM_record ZOOM_record_cache_lookup(ZOOM_resultset r, int pos, return &rc->rec; } } + npr = ZOOM_memcached_lookup(r, pos, syntax, elementSetName, schema); + if (npr) + return record_cache_add(r, npr, pos, syntax, elementSetName, + schema, 0); return 0; }