bes Updated for version 3.20.13
HttpCache.h
1
2// -*- mode: c++; c-basic-offset:4 -*-
3
4// This file is part of the BES http package, part of the Hyrax data server.
5
6// Copyright (c) 2020 OPeNDAP, Inc.
7// Author: Nathan Potter <ndp@opendap.org>
8//
9// This library is free software; you can redistribute it and/or
10// modify it under the terms of the GNU Lesser General Public
11// License as published by the Free Software Foundation; either
12// version 2.1 of the License, or (at your option) any later version.
13//
14// This library is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17// Lesser General Public License for more details.
18//
19// You should have received a copy of the GNU Lesser General Public
20// License along with this library; if not, write to the Free Software
21// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22//
23// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
24
25// Authors:
26// ndp Nathan Potter <ndp@opendap.org>
27
28#ifndef _bes_http_HTTP_CACHE_H_
29#define _bes_http_HTTP_CACHE_H_ 1
30
31#include "BESFileLockingCache.h"
32
33#define HASH_CACHE_FILENAME 1
34
35namespace http {
36
55 private:
56 static bool d_enabled;
57 static HttpCache *d_instance;
58
59 static void delete_instance() {
60 delete d_instance;
61 d_instance = 0;
62 }
63
64 HttpCache();
65
66 HttpCache(const HttpCache &src);
67
68 static std::string getCacheDirFromConfig();
69
70 static std::string getCachePrefixFromConfig();
71
72 static unsigned long getCacheSizeFromConfig();
73
74 protected:
81 HttpCache(const std::string &cache_dir, const std::string &prefix, unsigned long long size);
82
83 public:
84
85 //static HttpCache *
86 //get_instance(const std::string &cache_dir, const std::string &prefix, unsigned long long size);
87
88 static HttpCache *get_instance();
89
90 virtual ~HttpCache() {}
91
92#if HASH_CACHE_FILENAME
93 static std::string get_hash(const std::string &s);
94
95 virtual std::string get_cache_file_name(const std::string &uid, const std::string &src, bool mangle=true);
96
97 virtual std::string get_cache_file_name(const std::string &src, bool mangle=true);
98#endif
99
100 static unsigned long getCacheExpiresTime();
101 };
102
103} /* namespace http */
104
105#endif /* _bes_http_HTTP_CACHE_H_ */
Implementation of a caching mechanism for compressed data.
A cache for content accessed via HTTP.
Definition: HttpCache.h:54
static HttpCache * get_instance()
Definition: HttpCache.cc:188
virtual std::string get_cache_file_name(const std::string &uid, const std::string &src, bool mangle=true)
Definition: HttpCache.cc:282
utility class for the HTTP catalog module
Definition: AllowedHosts.cc:55