open-source-search-engine/Msg40Cache.cpp

32 lines
749 B
C++
Raw Normal View History

2013-08-03 00:12:24 +04:00
#include "gb-include.h"
#include "Msg40Cache.h"
// the global cache
Msg40Cache g_msg40Cache;
// returns true if we found in cache and set "msg40", false otherwise
bool Msg40Cache::setFromCache ( Msg40 *msg40 ) {
// make the key based on the input parms like # of docs wanted,
// start doc #, site clustering on, ...
key_t k = msg40->makeKey ( );
// look in cache, return false if not in there
if ( ! m_cache.getList ( k , k ,
&list ,
false , // do copy?
60*60*2 , // 2 hours max age
true )) // keep stats
return false;
// set the msg40 from the list's data buf
char *data = list.getList();
2014-11-11 01:45:11 +03:00
int32_t dataSize = list.getListSize();
2013-08-03 00:12:24 +04:00
setMsg40FromData ( msg40 , data , dataSize );
return true;
}