X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Fyaz-z-cache.cpp;h=1468b7df8af9e096e26ba71ee0bbfddd60feaa1f;hb=8cd77956b745e79b984bc0c9b74989aeae8dd49d;hp=8e521e6cd564894583c9b7cb15be70adf316c035;hpb=28588b9224eb5189af32b10f440ef2a917a05ea2;p=yazpp-moved-to-github.git diff --git a/src/yaz-z-cache.cpp b/src/yaz-z-cache.cpp index 8e521e6..1468b7d 100644 --- a/src/yaz-z-cache.cpp +++ b/src/yaz-z-cache.cpp @@ -2,7 +2,7 @@ * Copyright (c) 2002-2003, Index Data. * See the file LICENSE for details. * - * $Id: yaz-z-cache.cpp,v 1.5 2003-10-01 13:13:51 adam Exp $ + * $Id: yaz-z-cache.cpp,v 1.6 2003-10-08 08:52:59 adam Exp $ */ #include @@ -21,6 +21,7 @@ Yaz_RecordCache::Yaz_RecordCache () m_entries = 0; m_presentRequest = 0; m_searchRequest = 0; + m_max_size = 200000; } Yaz_RecordCache::~Yaz_RecordCache () @@ -28,6 +29,11 @@ Yaz_RecordCache::~Yaz_RecordCache () nmem_destroy(m_mem); } +void Yaz_RecordCache::set_max_size(int sz) +{ + m_max_size = sz; +} + void Yaz_RecordCache::clear () { nmem_destroy(m_mem); @@ -80,6 +86,8 @@ void Yaz_RecordCache::copy_presentRequest(Z_PresentRequest *pr) void Yaz_RecordCache::add (ODR o, Z_NamePlusRecordList *npr, int start, int hits) { + if (nmem_total(m_mem) > m_max_size) + return; // Build appropriate compspec for this response Z_RecordComposition *comp = 0; if (hits == -1 && m_presentRequest)