Mercurial > hg > nginx
comparison src/http/ngx_http_cache.h @ 197:0b81c7a0b133
nginx-0.0.1-2003-11-27-10:45:22 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 27 Nov 2003 07:45:22 +0000 |
parents | 8dee38ea9117 |
children | a65b630b3a66 |
comparison
equal
deleted
inserted
replaced
196:11fbd0fc041d | 197:0b81c7a0b133 |
---|---|
3 | 3 |
4 | 4 |
5 #include <ngx_config.h> | 5 #include <ngx_config.h> |
6 #include <ngx_core.h> | 6 #include <ngx_core.h> |
7 #include <ngx_http.h> | 7 #include <ngx_http.h> |
8 | |
9 | |
10 typedef struct { | |
11 uint32_t crc; | |
12 ngx_str_t key; | |
13 time_t accessed; | |
14 | |
15 unsigned refs:20; /* 1048576 references */ | |
16 unsigned count:2; /* lazy allocation: the 4 uses */ | |
17 unsigned deleted:1; | |
18 | |
19 ngx_fd_t fd; | |
20 time_t last_modified; | |
21 time_t updated; | |
22 | |
23 union { | |
24 off_t size; | |
25 ngx_str_t value; | |
26 } data; | |
27 } ngx_http_cache_t; | |
8 | 28 |
9 | 29 |
10 typedef struct { | 30 typedef struct { |
11 time_t expires; | 31 time_t expires; |
12 time_t last_modified; | 32 time_t last_modified; |
15 size_t key_len; | 35 size_t key_len; |
16 char key[1]; | 36 char key[1]; |
17 } ngx_http_cache_header_t; | 37 } ngx_http_cache_header_t; |
18 | 38 |
19 | 39 |
20 typedef struct { | 40 #define NGX_HTTP_CACHE_HASH 7 |
21 uint32_t crc; | |
22 ngx_str_t key; | |
23 ngx_fd_t fd; | |
24 off_t size; | |
25 void *data; /* mmap, memory */ | |
26 time_t accessed; | |
27 time_t last_modified; | |
28 time_t updated; /* no needed with kqueue */ | |
29 int refs; | |
30 int flags; | |
31 } ngx_http_cache_entry_t; | |
32 | |
33 #define NGX_HTTP_CACHE_HASH 1021 | |
34 #define NGX_HTTP_CACHE_NELTS 4 | 41 #define NGX_HTTP_CACHE_NELTS 4 |
35 | 42 |
36 typedef struct { | 43 typedef struct { |
37 ngx_http_cache_entry_t **cache; | 44 ngx_http_cache_t *elts; |
38 size_t hash; | 45 size_t hash; |
39 size_t nelts; | 46 size_t nelts; |
40 time_t life_time; | 47 time_t life_time; |
41 time_t check_time; | 48 time_t check_time; |
42 ngx_pool_t *pool; | 49 ngx_pool_t *pool; |
43 } ngx_http_cache_hash_t; | 50 } ngx_http_cache_hash_t; |
44 | 51 |
45 | 52 |
46 typedef struct { | 53 typedef struct { |
47 ngx_http_cache_hash_t *hash; | 54 ngx_http_cache_hash_t *hash; |
48 } ngx_http_cache_conf_t; | 55 ngx_http_cache_t *cache; |
49 | |
50 | |
51 typedef struct { | |
52 ngx_http_cache_hash_t *hash; | |
53 ngx_http_cache_entry_t *cache; | |
54 ngx_file_t file; | 56 ngx_file_t file; |
55 ngx_str_t key; | 57 ngx_str_t key; |
56 uint32_t crc; | 58 uint32_t crc; |
57 u_char md5[16]; | 59 u_char md5[16]; |
58 ngx_path_t *path; | 60 ngx_path_t *path; |
65 size_t file_start; | 67 size_t file_start; |
66 ngx_log_t *log; | 68 ngx_log_t *log; |
67 } ngx_http_cache_ctx_t; | 69 } ngx_http_cache_ctx_t; |
68 | 70 |
69 | 71 |
72 typedef struct { | |
73 ngx_http_cache_hash_t *open_files; | |
74 } ngx_http_cache_conf_t; | |
75 | |
76 | |
70 #define NGX_HTTP_CACHE_STALE 1 | 77 #define NGX_HTTP_CACHE_STALE 1 |
71 #define NGX_HTTP_CACHE_AGED 2 | 78 #define NGX_HTTP_CACHE_AGED 2 |
72 #define NGX_HTTP_CACHE_THE_SAME 3 | 79 #define NGX_HTTP_CACHE_THE_SAME 3 |
73 | 80 |
74 | 81 |
75 int ngx_http_cache_get_file(ngx_http_request_t *r, ngx_http_cache_ctx_t *ctx); | 82 int ngx_http_cache_get_file(ngx_http_request_t *r, ngx_http_cache_ctx_t *ctx); |
76 int ngx_http_cache_open_file(ngx_http_cache_ctx_t *ctx, ngx_file_uniq_t uniq); | 83 int ngx_http_cache_open_file(ngx_http_cache_ctx_t *ctx, ngx_file_uniq_t uniq); |
84 int ngx_http_cache_update_file(ngx_http_request_t *r,ngx_http_cache_ctx_t *ctx, | |
85 ngx_str_t *temp_file); | |
86 | |
87 ngx_http_cache_t *ngx_http_cache_get(ngx_http_cache_hash_t *cache, | |
88 ngx_str_t *key, uint32_t *crc); | |
89 ngx_http_cache_t *ngx_http_cache_alloc(ngx_http_cache_hash_t *cache, | |
90 ngx_str_t *key, uint32_t crc, | |
91 ngx_log_t *log); | |
92 | |
77 int ngx_garbage_collector_http_cache_handler(ngx_gc_t *gc, ngx_str_t *name, | 93 int ngx_garbage_collector_http_cache_handler(ngx_gc_t *gc, ngx_str_t *name, |
78 ngx_dir_t *dir); | 94 ngx_dir_t *dir); |
79 int ngx_http_cache_update_file(ngx_http_request_t *r,ngx_http_cache_ctx_t *ctx, | 95 |
80 ngx_str_t *temp_file); | 96 extern ngx_module_t ngx_http_cache_module; |
81 | 97 |
82 | 98 |
83 | 99 |
84 #endif /* _NGX_HTTP_CACHE_H_INCLUDED_ */ | 100 #endif /* _NGX_HTTP_CACHE_H_INCLUDED_ */ |