|
|
|
|
@ -344,7 +344,7 @@ Query_Cache::~Query_Cache() {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
unsigned char * Query_Cache::get(uint64_t user_hash, const unsigned char *kp, const uint32_t kl, uint32_t *lv, unsigned long long curtime_ms) {
|
|
|
|
|
unsigned char * Query_Cache::get(uint64_t user_hash, const unsigned char *kp, const uint32_t kl, uint32_t *lv, unsigned long long curtime_ms, unsigned long long cache_ttl) {
|
|
|
|
|
unsigned char *result=NULL;
|
|
|
|
|
|
|
|
|
|
uint64_t hk=SpookyHash::Hash64(kp, kl, user_hash);
|
|
|
|
|
@ -354,7 +354,7 @@ unsigned char * Query_Cache::get(uint64_t user_hash, const unsigned char *kp, co
|
|
|
|
|
|
|
|
|
|
if (entry!=NULL) {
|
|
|
|
|
unsigned long long t=curtime_ms;
|
|
|
|
|
if (entry->expire_ms > t) {
|
|
|
|
|
if (entry->expire_ms > t && entry->create_ms + cache_ttl > t) {
|
|
|
|
|
THR_UPDATE_CNT(__thr_cntGetOK,Glo_cntGetOK,1,1);
|
|
|
|
|
THR_UPDATE_CNT(__thr_dataOUT,Glo_dataOUT,entry->length,1);
|
|
|
|
|
result=(unsigned char *)malloc(entry->length);
|
|
|
|
|
@ -367,7 +367,7 @@ unsigned char * Query_Cache::get(uint64_t user_hash, const unsigned char *kp, co
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Query_Cache::set(uint64_t user_hash, const unsigned char *kp, uint32_t kl, unsigned char *vp, uint32_t vl, unsigned long long curtime_ms, unsigned long long expire_ms) {
|
|
|
|
|
bool Query_Cache::set(uint64_t user_hash, const unsigned char *kp, uint32_t kl, unsigned char *vp, uint32_t vl, unsigned long long create_ms, unsigned long long curtime_ms, unsigned long long expire_ms) {
|
|
|
|
|
QC_entry_t *entry = (QC_entry_t *)malloc(sizeof(QC_entry_t));
|
|
|
|
|
entry->klen=kl;
|
|
|
|
|
entry->length=vl;
|
|
|
|
|
@ -376,6 +376,7 @@ bool Query_Cache::set(uint64_t user_hash, const unsigned char *kp, uint32_t kl,
|
|
|
|
|
entry->value=(char *)malloc(vl);
|
|
|
|
|
memcpy(entry->value,vp,vl);
|
|
|
|
|
entry->self=entry;
|
|
|
|
|
entry->create_ms=create_ms;
|
|
|
|
|
entry->access_ms=curtime_ms;
|
|
|
|
|
entry->expire_ms=expire_ms;
|
|
|
|
|
uint64_t hk=SpookyHash::Hash64(kp, kl, user_hash);
|
|
|
|
|
|