bes  Updated for version 3.20.5
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 string getCacheDirFromConfig();
61  static string getCachePrefixFromConfig();
62  static unsigned long getCacheSizeFromConfig();
63 
64 protected:
65  RemoteHttpResourceCache(const string &cache_dir, const string &prefix, unsigned long long size);
66 
67 public:
68  static const string DIR_KEY;
69  static const string PREFIX_KEY;
70  static const string SIZE_KEY;
71 
72  static RemoteHttpResourceCache *get_instance(const string &cache_dir, const string &prefix, unsigned long long size);
74 
75  virtual string get_cache_file_name(const string &src, bool mangle=true);
76  inline string get_hash(const string &name);
77 
78  virtual ~RemoteHttpResourceCache() { }
79 };
80 
81 } /* namespace httpd_catalog */
82 
83 #endif /* _HttpCatalogCache_H_ */
static RemoteHttpResourceCache * get_instance()
Implementation of a caching mechanism for compressed data.
A cache for content accessed via HTTP.
virtual string get_cache_file_name(const string &src, bool mangle=true)