bes  Updated for version 3.20.6
RemoteHttpResourceCache.h
1 
2 // -*- mode: c++; c-basic-offset:4 -*-
3 
4 // This file is part of cmr_module, A C++ module that can be loaded in to
5 // the OPeNDAP Back-End Server (BES) and is able to handle remote requests.
6 
7 // Copyright (c) 2018 OPeNDAP, Inc.
8 // Author: Nathan Potter <ndp@opendap.org>
9 //
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 //
24 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25 
26 #ifndef _HttpCatalogCache_H_
27 #define _HttpCatalogCache_H_
28 
29 #include "BESFileLockingCache.h"
30 
31 namespace httpd_catalog {
32 
51 {
52 private:
53  static bool d_enabled;
54  static RemoteHttpResourceCache * d_instance;
55  static void delete_instance() { delete d_instance; d_instance = 0; }
56 
59 
60  static std::string getCacheDirFromConfig();
61  static std::string getCachePrefixFromConfig();
62  static unsigned long getCacheSizeFromConfig();
63 
64 protected:
65  RemoteHttpResourceCache(const std::string &cache_dir, const std::string &prefix, unsigned long long size);
66 
67 public:
68  static const std::string DIR_KEY;
69  static const std::string PREFIX_KEY;
70  static const std::string SIZE_KEY;
71 
72  static RemoteHttpResourceCache *get_instance(const std::string &cache_dir, const std::string &prefix, unsigned long long size);
74 
75  virtual std::string get_cache_file_name(const std::string &src, bool mangle=true);
76  inline std::string get_hash(const std::string &name);
77 
78  virtual ~RemoteHttpResourceCache() { }
79 };
80 
81 } /* namespace httpd_catalog */
82 
83 #endif /* _HttpCatalogCache_H_ */
httpd_catalog::RemoteHttpResourceCache::get_instance
static RemoteHttpResourceCache * get_instance()
Definition: RemoteHttpResourceCache.cc:167
httpd_catalog::RemoteHttpResourceCache::get_hash
std::string get_hash(const std::string &name)
Definition: RemoteHttpResourceCache.cc:198
httpd_catalog::RemoteHttpResourceCache
A cache for content accessed via HTTP.
Definition: RemoteHttpResourceCache.h:50
BESFileLockingCache
Implementation of a caching mechanism for compressed data.
Definition: BESFileLockingCache.h:85
httpd_catalog::RemoteHttpResourceCache::get_cache_file_name
virtual std::string get_cache_file_name(const std::string &src, bool mangle=true)
Definition: RemoteHttpResourceCache.cc:204