From: Adam Dickmeiss Date: Wed, 8 Oct 2003 08:52:59 +0000 (+0000) Subject: Limit record cache size X-Git-Tag: YAZPP.0.7.pre1~4 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=3925b97e468538ef3394b99896e19ac5d3120b5f;p=yazpp-moved-to-github.git Limit record cache size --- diff --git a/include/yaz++/proxy.h b/include/yaz++/proxy.h index 8535546..7326391 100644 --- a/include/yaz++/proxy.h +++ b/include/yaz++/proxy.h @@ -2,7 +2,7 @@ * Copyright (c) 1998-2003, Index Data. * See the file LICENSE for details. * - * $Id: proxy.h,v 1.11 2003-10-08 08:15:01 adam Exp $ + * $Id: proxy.h,v 1.12 2003-10-08 08:53:08 adam Exp $ */ #include @@ -68,6 +68,7 @@ class YAZ_EXPORT Yaz_RecordCache { void copy_searchRequest(Z_SearchRequest *sr); void copy_presentRequest(Z_PresentRequest *pr); + void set_max_size(int sz); private: NMEM m_mem; Yaz_RecordCache_Entry *m_entries; @@ -76,6 +77,7 @@ class YAZ_EXPORT Yaz_RecordCache { int match (Yaz_RecordCache_Entry *entry, Odr_oid *syntax, int offset, Z_RecordComposition *comp); + int m_max_size; }; class YAZ_EXPORT Yaz_bw { 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)