mirror of
https://github.com/nginx/nginx.git
synced 2025-06-13 06:12:44 +08:00
ngx_http_file_cache_create()
This commit is contained in:
parent
9e9cbee81e
commit
9aa3d7f667
@ -121,6 +121,7 @@ struct ngx_http_file_cache_s {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
ngx_int_t ngx_http_file_cache_create(ngx_http_request_t *r);
|
||||||
void ngx_http_file_cache_create_key(ngx_http_request_t *r);
|
void ngx_http_file_cache_create_key(ngx_http_request_t *r);
|
||||||
ngx_int_t ngx_http_file_cache_open(ngx_http_request_t *r);
|
ngx_int_t ngx_http_file_cache_open(ngx_http_request_t *r);
|
||||||
void ngx_http_file_cache_set_header(ngx_http_request_t *r, u_char *buf);
|
void ngx_http_file_cache_set_header(ngx_http_request_t *r, u_char *buf);
|
||||||
|
@ -144,6 +144,27 @@ ngx_http_file_cache_init(ngx_shm_zone_t *shm_zone, void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ngx_int_t
|
||||||
|
ngx_http_file_cache_create(ngx_http_request_t *r)
|
||||||
|
{
|
||||||
|
ngx_http_cache_t *c;
|
||||||
|
|
||||||
|
c = ngx_pcalloc(r->pool, sizeof(ngx_http_cache_t));
|
||||||
|
if (c == NULL) {
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ngx_array_init(&c->keys, r->pool, 4, sizeof(ngx_str_t)) != NGX_OK) {
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
r->cache = c;
|
||||||
|
c->file.log = r->connection->log;
|
||||||
|
|
||||||
|
return NGX_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ngx_http_file_cache_create_key(ngx_http_request_t *r)
|
ngx_http_file_cache_create_key(ngx_http_request_t *r)
|
||||||
{
|
{
|
||||||
|
@ -646,18 +646,10 @@ ngx_http_upstream_cache(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
|||||||
u->method = ngx_http_core_get_method;
|
u->method = ngx_http_core_get_method;
|
||||||
}
|
}
|
||||||
|
|
||||||
c = ngx_pcalloc(r->pool, sizeof(ngx_http_cache_t));
|
if (ngx_http_file_cache_create(r) != NGX_OK) {
|
||||||
if (c == NULL) {
|
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ngx_array_init(&c->keys, r->pool, 4, sizeof(ngx_str_t)) != NGX_OK) {
|
|
||||||
return NGX_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
r->cache = c;
|
|
||||||
c->file.log = r->connection->log;
|
|
||||||
|
|
||||||
if (u->create_key(r) != NGX_OK) {
|
if (u->create_key(r) != NGX_OK) {
|
||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
@ -668,6 +660,8 @@ ngx_http_upstream_cache(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
|||||||
|
|
||||||
u->cacheable = 1;
|
u->cacheable = 1;
|
||||||
|
|
||||||
|
c = r->cache;
|
||||||
|
|
||||||
c->min_uses = u->conf->cache_min_uses;
|
c->min_uses = u->conf->cache_min_uses;
|
||||||
c->body_start = u->conf->buffer_size;
|
c->body_start = u->conf->buffer_size;
|
||||||
c->file_cache = u->conf->cache->data;
|
c->file_cache = u->conf->cache->data;
|
||||||
|
Loading…
Reference in New Issue
Block a user