bes Updated for version 3.20.13
EffectiveUrlCache.h
1// -*- mode: c++; c-basic-offset:4 -*-
2
3// This file is part of the BES http package, part of the Hyrax data server.
4
5// Copyright (c) 2020 OPeNDAP, Inc.
6// Author: Nathan Potter <ndp@opendap.org>
7//
8// This library is free software; you can redistribute it and/or
9// modify it under the terms of the GNU Lesser General Public
10// License as published by the Free Software Foundation; either
11// version 2.1 of the License, or (at your option) any later version.
12//
13// This library is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16// Lesser General Public License for more details.
17//
18// You should have received a copy of the GNU Lesser General Public
19// License along with this library; if not, write to the Free Software
20// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21//
22// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
23
24// Authors:
25// ndp Nathan Potter <ndp@opendap.org>
26
27#ifndef _bes_http_EffectiveUrlCache_h_
28#define _bes_http_EffectiveUrlCache_h_ 1
29
30#include <memory>
31#include <map>
32#include <string>
33#include <mutex>
34
35#include "BESObj.h"
36#include "BESDataHandlerInterface.h"
37#include "BESRegex.h"
38#include "EffectiveUrl.h"
39
40namespace http {
41
42
51private:
52 static EffectiveUrlCache * d_instance;
53 std::mutex d_cache_lock_mutex;
54
55 std::map<std::string , std::shared_ptr<http::EffectiveUrl>> d_effective_urls;
56
57 // Things that match get skipped.
58 BESRegex *d_skip_regex;
59
60 int d_enabled;
61
62 static void initialize_instance();
63 static void delete_instance();
64
65 std::shared_ptr<EffectiveUrl> get_cached_eurl(std::string const &url_key);
66 BESRegex *get_skip_regex();
67 bool is_enabled();
68
69 EffectiveUrlCache(): d_skip_regex(nullptr), d_enabled(-1){}
70
71 ~EffectiveUrlCache() override;
72
73 friend class EffectiveUrlCacheTest;
74
75public:
76
78
79 std::shared_ptr<EffectiveUrl> get_effective_url(std::shared_ptr<url> source_url);
80
81 void dump(std::ostream &strm) const override;
82 virtual std::string dump() const;
83
84};
85
86} // namespace http
87
88#endif // _bes_http_EffectiveUrlCache_h_
89
top level BES object to house generic methods
Definition: BESObj.h:54
Regular expression matching.
Definition: BESRegex.h:53
static EffectiveUrlCache * TheCache()
Get the singleton EffectiveUrlCache instance.
virtual std::string dump() const
dumps information about this object
std::shared_ptr< EffectiveUrl > get_effective_url(std::shared_ptr< url > source_url)
utility class for the HTTP catalog module
Definition: AllowedHosts.cc:55