]> granicus.if.org Git - apache/blob - modules/cache/mod_disk_cache.h
f16801b343425c6da1a50ee2d3180c1957db7922
[apache] / modules / cache / mod_disk_cache.h
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements.  See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License.  You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef MOD_DISK_CACHE_H
18 #define MOD_DISK_CACHE_H
19
20 #include "mod_cache.h"
21 #include "apr_file_io.h"
22
23 #include "cache_common.h"
24
25 /*
26  * include for mod_disk_cache: Disk Based HTTP 1.1 Cache.
27  */
28
29 typedef struct {
30     apr_pool_t *pool;
31     const char *file;
32     apr_file_t *fd;
33     char *tempfile;
34     apr_file_t *tempfd;
35 } disk_cache_file_t;
36
37 /*
38  * disk_cache_object_t
39  * Pointed to by cache_object_t::vobj
40  */
41 typedef struct disk_cache_object {
42     const char *root;            /* the location of the cache directory */
43     apr_size_t root_len;
44     const char *prefix;
45     disk_cache_file_t data;      /* data file structure */
46     disk_cache_file_t hdrs;      /* headers file structure */
47     disk_cache_file_t vary;      /* vary file structure */
48     const char *hashfile;        /* Computed hash key for this URI */
49     const char *name;            /* Requested URI without vary bits - suitable for mortals. */
50     const char *key;             /* On-disk prefix; URI with Vary bits (if present) */
51     apr_off_t file_size;         /*  File size of the cached data file  */
52     disk_cache_info_t disk_info; /* Header information. */
53     apr_bucket_brigade *bb;      /* Set aside brigade */
54     apr_table_t *headers_in;     /* Input headers to save */
55     apr_table_t *headers_out;    /* Output headers to save */
56     apr_off_t offset;            /* Max size to set aside */
57     apr_time_t timeout;          /* Max time to set aside */
58     int done:1;                  /* Is the attempt to cache complete? */
59 } disk_cache_object_t;
60
61
62 /*
63  * mod_disk_cache configuration
64  */
65 /* TODO: Make defaults OS specific */
66 #define CACHEFILE_LEN 20        /* must be less than HASH_LEN/2 */
67 #define DEFAULT_DIRLEVELS 2
68 #define DEFAULT_DIRLENGTH 2
69 #define DEFAULT_MIN_FILE_SIZE 1
70 #define DEFAULT_MAX_FILE_SIZE 1000000
71 #define DEFAULT_READSIZE 0
72 #define DEFAULT_READTIME 0
73
74 typedef struct {
75     const char* cache_root;
76     apr_size_t cache_root_len;
77     int dirlevels;               /* Number of levels of subdirectories */
78     int dirlength;               /* Length of subdirectory names */
79 } disk_cache_conf;
80
81 typedef struct {
82     apr_off_t minfs;             /* minimum file size for cached files */
83     apr_off_t maxfs;             /* maximum file size for cached files */
84     apr_off_t readsize;          /* maximum data to attempt to cache in one go */
85     apr_time_t readtime;         /* maximum time taken to cache in one go */
86     int minfs_set:1;
87     int maxfs_set:1;
88     int readsize_set:1;
89     int readtime_set:1;
90 } disk_cache_dir_conf;
91
92 #endif /*MOD_DISK_CACHE_H*/