added --load-file-in-cache

This commit is contained in:
Roberto De Ioris
2013-01-12 20:00:43 +01:00
parent cf682773fb
commit 7da87bdf9d
2 changed files with 11 additions and 4 deletions
+1 -1
View File
@@ -189,7 +189,7 @@ static struct uwsgi_option uwsgi_base_options[] = {
{"cache-udp-node", required_argument, 0, "send cache update/deletion to the specified cache udp server", uwsgi_opt_add_string_list, &uwsgi.cache_udp_node, UWSGI_OPT_MASTER},
{"cache-sync", required_argument, 0, "copy the whole content of another uWSGI cache server on server startup", uwsgi_opt_set_str, &uwsgi.cache_sync, 0},
{"load-file-in-cache", required_argument, 0, "load a static file in the cache", uwsgi_opt_add_string_list, &uwsgi.load_file_in_cache, UWSGI_OPT_MASTER},
{"load-file-in-cache", required_argument, 0, "load a static file in the cache", uwsgi_opt_add_string_list, &uwsgi.load_file_in_cache, 0},
{"queue", required_argument, 0, "enable shared queue", uwsgi_opt_set_int, &uwsgi.queue_size, 0},
+10 -3
View File
@@ -20,6 +20,7 @@ extern struct uwsgi_server uwsgi;
struct uwsgi_router_cache_conf {
char *key;
size_t key_len;
char *var;
char *type;
@@ -49,7 +50,7 @@ static int uwsgi_routing_func_cache(struct wsgi_request *wsgi_req, struct uwsgi_
char **subject = (char **) (((char *)(wsgi_req))+ur->subject);
uint16_t *subject_len = (uint16_t *) (((char *)(wsgi_req))+ur->subject_len);
c_k = uwsgi_regexp_apply_ovec(*subject, *subject_len, ur->data, ur->data_len, ur->ovector, ur->ovn);
c_k = uwsgi_regexp_apply_ovec(*subject, *subject_len, urcc->key, urcc->key_len, ur->ovector, ur->ovn);
c_k_len = strlen(c_k);
k_need_free = 1;
}
@@ -105,6 +106,10 @@ static int uwsgi_router_cache(struct uwsgi_route *ur, char *args) {
exit(1);
}
if (urcc->key) {
urcc->key_len = strlen(urcc->key);
}
if (!urcc->key && !urcc->var) {
uwsgi_log("invalid route syntax: you need to specify a cache key or var\n");
exit(1);
@@ -115,11 +120,12 @@ static int uwsgi_router_cache(struct uwsgi_route *ur, char *args) {
urcc->content_type_len = strlen(urcc->content_type);
if (!strcmp(urcc->key, "REQUEST_URI")) {
if (urcc->var) {
if (!strcmp(urcc->var, "REQUEST_URI")) {
urcc->var_offset = offsetof(struct wsgi_request, uri);
urcc->var_offset_len = offsetof(struct wsgi_request, uri_len);
}
else if (!strcmp(urcc->key, "PATH_INFO")) {
else if (!strcmp(urcc->var, "PATH_INFO")) {
urcc->var_offset = offsetof(struct wsgi_request, path_info);
urcc->var_offset_len = offsetof(struct wsgi_request, path_info_len);
}
@@ -127,6 +133,7 @@ static int uwsgi_router_cache(struct uwsgi_route *ur, char *args) {
urcc->var_offset = offsetof(struct wsgi_request, uri);
urcc->var_offset_len = offsetof(struct wsgi_request, uri_len);
}
}
if (!strcmp(urcc->type, "body")) {
urcc->type_num = 1;