Browse Source

allow record expiration to be disabled

master
Brett Langdon 13 years ago
parent
commit
9345142866
2 changed files with 6 additions and 3 deletions
  1. +1
    -1
      src/main.c
  2. +5
    -2
      src/proxy.c

+ 1
- 1
src/main.c View File

@ -36,7 +36,7 @@ void usage(){
"\t-w, --workers\t- how many background workers to spawn [default: 10]\r\n" "\t-w, --workers\t- how many background workers to spawn [default: 10]\r\n"
"\t-u, --url\t- which url to proxy requests to [default: http://127.0.0.1:8000]\r\n" "\t-u, --url\t- which url to proxy requests to [default: http://127.0.0.1:8000]\r\n"
"\t-c, --cache\t- kyoto cabinet cache to use [default: \"*\"]\r\n" "\t-c, --cache\t- kyoto cabinet cache to use [default: \"*\"]\r\n"
"\t-e, --expire\t- the expiration time in seconds from when a record is cached [default:3600]\r\n"
"\t-e, --expire\t- the expiration time in seconds from when a record is cached, 0 to disable [default:3600]\r\n"
"\t-h, --help\t- display this message\r\n"; "\t-h, --help\t- display this message\r\n";
printf("%s", usage_str); printf("%s", usage_str);
} }


+ 5
- 2
src/proxy.c View File

@ -39,8 +39,11 @@ void* call_proxy(void* arg){
curl_easy_setopt(curl, CURLOPT_WRITEDATA, result); curl_easy_setopt(curl, CURLOPT_WRITEDATA, result);
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
char value[1024]; char value[1024];
int now = (int)time(NULL);
sprintf(value, "%10d:%s", now + record_expire_time, result->data);
int exp = 0;
if(record_expire_time > 0){
exp = (int)time(NULL) + record_expire_time;
}
sprintf(value, "%10d:%s", exp, result->data);
kcdbset(db, next, strlen(next), value, strlen(value)); kcdbset(db, next, strlen(next), value, strlen(value));
if(url != NULL){ if(url != NULL){


Loading…
Cancel
Save