|
4 | 4 | /* |
5 | 5 | * FileCache — Enhanced File Cache for libhv HTTP server |
6 | 6 | * |
7 | | - * Features: |
8 | | - * 1. Configurable max_header_length (default 4096, tunable per-instance) |
9 | | - * 2. prepend_header() returns bool to report success/failure |
10 | | - * 3. Exposes header/buffer metrics via accessors |
11 | | - * 4. Fixes stat() name collision in is_modified() |
12 | | - * 5. max_cache_num / max_file_size configurable at runtime |
13 | | - * 6. Reserved header space can be tuned per-instance |
14 | | - * 7. Source-level API compatible; struct layout differs from original (no ABI/layout compatibility) |
15 | 7 | */ |
16 | 8 |
|
17 | 9 | #include <memory> |
@@ -42,7 +34,6 @@ typedef struct file_cache_s { |
42 | 34 | char etag[64]; |
43 | 35 | std::string content_type; |
44 | 36 |
|
45 | | - // --- new: expose header metrics --- |
46 | 37 | int header_reserve; // reserved bytes before file content |
47 | 38 | int header_used; // actual bytes used by prepend_header |
48 | 39 |
|
@@ -114,7 +105,6 @@ typedef std::shared_ptr<file_cache_t> file_cache_ptr; |
114 | 105 |
|
115 | 106 | class HV_EXPORT FileCache : public hv::LRUCache<std::string, file_cache_ptr> { |
116 | 107 | public: |
117 | | - // --- configurable parameters (were hardcoded macros before) --- |
118 | 108 | int stat_interval; // seconds between stat() checks |
119 | 109 | int expired_time; // seconds before cache entry expires |
120 | 110 | int max_header_length; // reserved header bytes per entry |
@@ -143,13 +133,11 @@ class HV_EXPORT FileCache : public hv::LRUCache<std::string, file_cache_ptr> { |
143 | 133 | bool Close(const char* filepath); |
144 | 134 | void RemoveExpiredFileCache(); |
145 | 135 |
|
146 | | - // --- new: getters --- |
147 | 136 | int GetMaxHeaderLength() const { return max_header_length; } |
148 | 137 | int GetMaxFileSize() const { return max_file_size; } |
149 | 138 | int GetStatInterval() const { return stat_interval; } |
150 | 139 | int GetExpiredTime() const { return expired_time; } |
151 | 140 |
|
152 | | - // --- new: setters --- |
153 | 141 | void SetMaxHeaderLength(int len) { max_header_length = len < 0 ? 0 : len; } |
154 | 142 | void SetMaxFileSize(int size) { max_file_size = size < 1 ? 1 : size; } |
155 | 143 |
|
|
0 commit comments