Annotation of embedaddon/nginx/src/http/ngx_http_cache.h, revision 1.1.1.1
1.1 misho 1:
2: /*
3: * Copyright (C) Igor Sysoev
4: * Copyright (C) Nginx, Inc.
5: */
6:
7:
8: #ifndef _NGX_HTTP_CACHE_H_INCLUDED_
9: #define _NGX_HTTP_CACHE_H_INCLUDED_
10:
11:
12: #include <ngx_config.h>
13: #include <ngx_core.h>
14: #include <ngx_http.h>
15:
16:
17: #define NGX_HTTP_CACHE_MISS 1
18: #define NGX_HTTP_CACHE_BYPASS 2
19: #define NGX_HTTP_CACHE_EXPIRED 3
20: #define NGX_HTTP_CACHE_STALE 4
21: #define NGX_HTTP_CACHE_UPDATING 5
22: #define NGX_HTTP_CACHE_HIT 6
23: #define NGX_HTTP_CACHE_SCARCE 7
24:
25: #define NGX_HTTP_CACHE_KEY_LEN 16
26:
27:
28: typedef struct {
29: ngx_uint_t status;
30: time_t valid;
31: } ngx_http_cache_valid_t;
32:
33:
34: typedef struct {
35: ngx_rbtree_node_t node;
36: ngx_queue_t queue;
37:
38: u_char key[NGX_HTTP_CACHE_KEY_LEN
39: - sizeof(ngx_rbtree_key_t)];
40:
41: unsigned count:20;
42: unsigned uses:10;
43: unsigned valid_msec:10;
44: unsigned error:10;
45: unsigned exists:1;
46: unsigned updating:1;
47: unsigned deleting:1;
48: /* 11 unused bits */
49:
50: ngx_file_uniq_t uniq;
51: time_t expire;
52: time_t valid_sec;
53: size_t body_start;
54: off_t fs_size;
55: } ngx_http_file_cache_node_t;
56:
57:
58: struct ngx_http_cache_s {
59: ngx_file_t file;
60: ngx_array_t keys;
61: uint32_t crc32;
62: u_char key[NGX_HTTP_CACHE_KEY_LEN];
63:
64: ngx_file_uniq_t uniq;
65: time_t valid_sec;
66: time_t last_modified;
67: time_t date;
68:
69: size_t header_start;
70: size_t body_start;
71: off_t length;
72: off_t fs_size;
73:
74: ngx_uint_t min_uses;
75: ngx_uint_t error;
76: ngx_uint_t valid_msec;
77:
78: ngx_buf_t *buf;
79:
80: ngx_http_file_cache_t *file_cache;
81: ngx_http_file_cache_node_t *node;
82:
83: ngx_msec_t lock_timeout;
84: ngx_msec_t wait_time;
85:
86: ngx_event_t wait_event;
87:
88: unsigned lock:1;
89: unsigned waiting:1;
90:
91: unsigned updated:1;
92: unsigned updating:1;
93: unsigned exists:1;
94: unsigned temp_file:1;
95: };
96:
97:
98: typedef struct {
99: time_t valid_sec;
100: time_t last_modified;
101: time_t date;
102: uint32_t crc32;
103: u_short valid_msec;
104: u_short header_start;
105: u_short body_start;
106: } ngx_http_file_cache_header_t;
107:
108:
109: typedef struct {
110: ngx_rbtree_t rbtree;
111: ngx_rbtree_node_t sentinel;
112: ngx_queue_t queue;
113: ngx_atomic_t cold;
114: ngx_atomic_t loading;
115: off_t size;
116: } ngx_http_file_cache_sh_t;
117:
118:
119: struct ngx_http_file_cache_s {
120: ngx_http_file_cache_sh_t *sh;
121: ngx_slab_pool_t *shpool;
122:
123: ngx_path_t *path;
124:
125: off_t max_size;
126: size_t bsize;
127:
128: time_t inactive;
129:
130: ngx_uint_t files;
131: ngx_uint_t loader_files;
132: ngx_msec_t last;
133: ngx_msec_t loader_sleep;
134: ngx_msec_t loader_threshold;
135:
136: ngx_shm_zone_t *shm_zone;
137: };
138:
139:
140: ngx_int_t ngx_http_file_cache_new(ngx_http_request_t *r);
141: ngx_int_t ngx_http_file_cache_create(ngx_http_request_t *r);
142: void ngx_http_file_cache_create_key(ngx_http_request_t *r);
143: ngx_int_t ngx_http_file_cache_open(ngx_http_request_t *r);
144: void ngx_http_file_cache_set_header(ngx_http_request_t *r, u_char *buf);
145: void ngx_http_file_cache_update(ngx_http_request_t *r, ngx_temp_file_t *tf);
146: ngx_int_t ngx_http_cache_send(ngx_http_request_t *);
147: void ngx_http_file_cache_free(ngx_http_cache_t *c, ngx_temp_file_t *tf);
148: time_t ngx_http_file_cache_valid(ngx_array_t *cache_valid, ngx_uint_t status);
149:
150: char *ngx_http_file_cache_set_slot(ngx_conf_t *cf, ngx_command_t *cmd,
151: void *conf);
152: char *ngx_http_file_cache_valid_set_slot(ngx_conf_t *cf, ngx_command_t *cmd,
153: void *conf);
154:
155:
156: extern ngx_str_t ngx_http_cache_status[];
157:
158:
159: #endif /* _NGX_HTTP_CACHE_H_INCLUDED_ */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>