mod_disk_cache.h revision dcb4802d9ea9fc4ba89671e8f8faa70c9535b202
1276N/A/* Licensed to the Apache Software Foundation (ASF) under one or more
1276N/A * contributor license agreements. See the NOTICE file distributed with
1276N/A * this work for additional information regarding copyright ownership.
1276N/A * The ASF licenses this file to You under the Apache License, Version 2.0
1276N/A * (the "License"); you may not use this file except in compliance with
486N/A * the License. You may obtain a copy of the License at
486N/A *
486N/A * http://www.apache.org/licenses/LICENSE-2.0
486N/A *
486N/A * Unless required by applicable law or agreed to in writing, software
486N/A * distributed under the License is distributed on an "AS IS" BASIS,
486N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
486N/A * See the License for the specific language governing permissions and
486N/A * limitations under the License.
1276N/A */
1068N/A
1068N/A#ifndef MOD_DISK_CACHE_H
486N/A#define MOD_DISK_CACHE_H
486N/A
486N/A#include "apr_file_io.h"
486N/A
486N/A/*
1276N/A * include for mod_disk_cache: Disk Based HTTP 1.1 Cache.
486N/A */
1276N/A
486N/A#define VARY_FORMAT_VERSION 5
1276N/A#define DISK_FORMAT_VERSION 6
486N/A
1276N/A#define CACHE_HEADER_SUFFIX ".header"
486N/A#define CACHE_DATA_SUFFIX ".data"
1276N/A#define CACHE_VDIR_SUFFIX ".vary"
486N/A
486N/A#define AP_TEMPFILE_PREFIX "/"
486N/A#define AP_TEMPFILE_BASE "aptmp"
1276N/A#define AP_TEMPFILE_SUFFIX "XXXXXX"
486N/A#define AP_TEMPFILE_BASELEN strlen(AP_TEMPFILE_BASE)
486N/A#define AP_TEMPFILE_NAMELEN strlen(AP_TEMPFILE_BASE AP_TEMPFILE_SUFFIX)
486N/A#define AP_TEMPFILE AP_TEMPFILE_PREFIX AP_TEMPFILE_BASE AP_TEMPFILE_SUFFIX
486N/A
486N/Atypedef struct {
486N/A /* Indicates the format of the header struct stored on-disk. */
486N/A apr_uint32_t format;
486N/A /* The HTTP status code returned for this response. */
486N/A int status;
486N/A /* The size of the entity name that follows. */
486N/A apr_size_t name_len;
486N/A /* The number of times we've cached this entity. */
486N/A apr_size_t entity_version;
486N/A /* Miscellaneous time values. */
486N/A apr_time_t date;
486N/A apr_time_t expire;
486N/A apr_time_t request_time;
486N/A apr_time_t response_time;
486N/A /* The ident of the body file, so we can test the body matches the header */
486N/A apr_ino_t inode;
486N/A apr_dev_t device;
486N/A /* Does this cached request have a body? */
486N/A int has_body;
1276N/A int header_only;
486N/A} disk_cache_info_t;
486N/A
486N/Atypedef struct {
486N/A apr_pool_t *pool;
486N/A const char *file;
486N/A apr_file_t *fd;
486N/A char *tempfile;
486N/A apr_file_t *tempfd;
486N/A} disk_cache_file_t;
486N/A
486N/A/*
486N/A * disk_cache_object_t
486N/A * Pointed to by cache_object_t::vobj
486N/A */
486N/Atypedef struct disk_cache_object {
486N/A const char *root; /* the location of the cache directory */
486N/A apr_size_t root_len;
486N/A const char *prefix;
486N/A disk_cache_file_t data; /* data file structure */
486N/A disk_cache_file_t hdrs; /* headers file structure */
1068N/A disk_cache_file_t vary; /* vary file structure */
486N/A const char *hashfile; /* Computed hash key for this URI */
486N/A const char *name; /* Requested URI without vary bits - suitable for mortals. */
486N/A const char *key; /* On-disk prefix; URI with Vary bits (if present) */
486N/A apr_off_t file_size; /* File size of the cached data file */
1068N/A disk_cache_info_t disk_info; /* Header information. */
486N/A apr_bucket_brigade *bb; /* Set aside brigade */
486N/A apr_table_t *headers_in; /* Input headers to save */
1276N/A apr_table_t *headers_out; /* Output headers to save */
486N/A apr_off_t offset; /* Max size to set aside */
486N/A apr_time_t timeout; /* Max time to set aside */
486N/A int done; /* Is the attempt to cache complete? */
486N/A} disk_cache_object_t;
486N/A
486N/A
486N/A/*
486N/A * mod_disk_cache configuration
486N/A */
486N/A/* TODO: Make defaults OS specific */
486N/A#define CACHEFILE_LEN 20 /* must be less than HASH_LEN/2 */
486N/A#define DEFAULT_DIRLEVELS 2
486N/A#define DEFAULT_DIRLENGTH 2
486N/A#define DEFAULT_MIN_FILE_SIZE 1
486N/A#define DEFAULT_MAX_FILE_SIZE 1000000
486N/A#define DEFAULT_READSIZE 0
486N/A#define DEFAULT_READTIME 0
486N/A
486N/Atypedef struct {
486N/A const char* cache_root;
1276N/A apr_size_t cache_root_len;
486N/A int dirlevels; /* Number of levels of subdirectories */
486N/A int dirlength; /* Length of subdirectory names */
1276N/A apr_off_t minfs; /* minimum file size for cached files */
486N/A apr_off_t maxfs; /* maximum file size for cached files */
486N/A} disk_cache_conf;
486N/A
486N/Atypedef struct {
486N/A apr_off_t readsize; /* maximum data to attempt to cache in one go */
1276N/A apr_time_t readtime; /* maximum time taken to cache in one go */
486N/A int readsize_set;
486N/A int readtime_set;
486N/A} disk_cache_dir_conf;
486N/A
486N/A#endif /*MOD_DISK_CACHE_H*/
486N/A