Mercurial > hg > nginx
comparison src/http/ngx_http_cache.h @ 201:267ea1d98683
nginx-0.0.1-2003-11-30-23:03:18 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sun, 30 Nov 2003 20:03:18 +0000 |
parents | abeaebe0a33c |
children | 74994aeef848 |
comparison
equal
deleted
inserted
replaced
200:abeaebe0a33c | 201:267ea1d98683 |
---|---|
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 | 8 |
9 | 9 |
10 /* | |
11 * The 7 uses before an allocation. | |
12 * We can use maximum 7 bits, i.e up to the 127 uses. | |
13 */ | |
14 #define NGX_HTTP_CACHE_LAZY_ALLOCATION_BITS 3 | |
15 | |
10 typedef struct { | 16 typedef struct { |
11 uint32_t crc; | 17 uint32_t crc; |
12 ngx_str_t key; | 18 ngx_str_t key; |
13 time_t accessed; | 19 time_t accessed; |
14 | 20 |
15 unsigned refs:20; /* 1048576 references */ | 21 unsigned refs:20; /* 1048576 references */ |
16 unsigned count:2; /* lazy allocation: the 4 uses */ | |
17 unsigned deleted:1; | |
18 | 22 |
19 ngx_fd_t fd; | 23 unsigned count:NGX_HTTP_CACHE_LAZY_ALLOCATION_BITS; |
20 time_t last_modified; | 24 |
21 time_t updated; | 25 unsigned valid:1; |
26 unsigned deleted:1; | |
27 unsigned memory:1; | |
28 unsigned mmap:1; | |
29 unsigned notify:1; | |
30 | |
31 ngx_fd_t fd; | |
32 #if (NGX_USE_HTTP_FILE_CACHE_UNIQ) | |
33 ngx_file_uniq_t uniq; /* no needed with kqueue */ | |
34 #endif | |
35 time_t last_modified; | |
36 time_t updated; | |
22 | 37 |
23 union { | 38 union { |
24 off_t size; | 39 off_t size; |
25 ngx_str_t value; | 40 ngx_str_t value; |
26 } data; | 41 } data; |
27 } ngx_http_cache_t; | 42 } ngx_http_cache_t; |
28 | 43 |
29 | 44 |
30 typedef struct { | 45 typedef struct { |
67 size_t file_start; | 82 size_t file_start; |
68 ngx_log_t *log; | 83 ngx_log_t *log; |
69 } ngx_http_cache_ctx_t; | 84 } ngx_http_cache_ctx_t; |
70 | 85 |
71 | 86 |
72 typedef struct { | |
73 ngx_http_cache_hash_t *open_files; | |
74 } ngx_http_cache_conf_t; | |
75 | |
76 | |
77 | 87 |
78 #define NGX_HTTP_CACHE_STALE 1 | 88 #define NGX_HTTP_CACHE_STALE 1 |
79 #define NGX_HTTP_CACHE_AGED 2 | 89 #define NGX_HTTP_CACHE_AGED 2 |
80 #define NGX_HTTP_CACHE_THE_SAME 3 | 90 #define NGX_HTTP_CACHE_THE_SAME 3 |
81 | 91 |
82 | 92 |
93 ngx_http_cache_t *ngx_http_cache_get(ngx_http_cache_hash_t *cache, | |
94 ngx_http_cleanup_t *cleanup, | |
95 ngx_str_t *key, uint32_t *crc); | |
96 | |
97 ngx_http_cache_t *ngx_http_cache_alloc(ngx_http_cache_hash_t *hash, | |
98 ngx_http_cache_t *cache, | |
99 ngx_http_cleanup_t *cleanup, | |
100 ngx_str_t *key, uint32_t crc, | |
101 ngx_str_t *value, ngx_log_t *log); | |
102 void ngx_http_cache_free(ngx_http_cache_t *cache, | |
103 ngx_str_t *key, ngx_str_t *value, ngx_log_t *log); | |
104 void ngx_http_cache_unlock(ngx_http_cache_hash_t *hash, | |
105 ngx_http_cache_t *cache, ngx_log_t *log); | |
106 | |
83 int ngx_http_cache_get_file(ngx_http_request_t *r, ngx_http_cache_ctx_t *ctx); | 107 int ngx_http_cache_get_file(ngx_http_request_t *r, ngx_http_cache_ctx_t *ctx); |
84 int ngx_http_cache_open_file(ngx_http_cache_ctx_t *ctx, ngx_file_uniq_t uniq); | 108 int ngx_http_cache_open_file(ngx_http_cache_ctx_t *ctx, ngx_file_uniq_t uniq); |
85 int ngx_http_cache_update_file(ngx_http_request_t *r,ngx_http_cache_ctx_t *ctx, | 109 int ngx_http_cache_update_file(ngx_http_request_t *r,ngx_http_cache_ctx_t *ctx, |
86 ngx_str_t *temp_file); | 110 ngx_str_t *temp_file); |
87 | 111 |
88 ngx_http_cache_t *ngx_http_cache_get(ngx_http_cache_hash_t *cache, | 112 int ngx_http_send_cached(ngx_http_request_t *r); |
89 ngx_str_t *key, uint32_t *crc); | |
90 ngx_http_cache_t *ngx_http_cache_alloc(ngx_http_cache_hash_t *cache, | |
91 ngx_str_t *key, uint32_t crc, | |
92 ngx_log_t *log); | |
93 void ngx_http_cache_unlock(ngx_http_cache_hash_t *hash, | |
94 ngx_http_cache_t *cache, ngx_log_t *log); | |
95 | 113 |
96 | 114 |
97 int ngx_garbage_collector_http_cache_handler(ngx_gc_t *gc, ngx_str_t *name, | 115 int ngx_garbage_collector_http_cache_handler(ngx_gc_t *gc, ngx_str_t *name, |
98 ngx_dir_t *dir); | 116 ngx_dir_t *dir); |
99 | 117 |
100 char *ngx_http_set_cache_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); | 118 char *ngx_http_set_cache_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); |
101 | 119 |
102 | 120 |
103 extern ngx_module_t ngx_http_cache_module; | |
104 | |
105 | |
106 | |
107 #endif /* _NGX_HTTP_CACHE_H_INCLUDED_ */ | 121 #endif /* _NGX_HTTP_CACHE_H_INCLUDED_ */ |