bes  Updated for version 3.20.6
CmrCache.h
1 // -*- mode: c++; c-basic-offset:4 -*-
2 
3 // This file is part of cmr_module, A C++ module that can be loaded in to
4 // the OPeNDAP Back-End Server (BES) and is able to handle remote requests.
5 
6 // Copyright (c) 2015 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 /*
26  * CmrCache.h
27  *
28  * Created on: July, 10 2018
29  * Author: ndp
30  */
31 
32 #ifndef MODULES_CMR_MODULE_CMRCACHE_H_
33 #define MODULES_CMR_MODULE_CMRCACHE_H_
34 
35 #include "BESFileLockingCache.h"
36 
37 namespace cmr {
38 
57 {
58 private:
59  static bool d_enabled;
60  static CmrCache * d_instance;
61  static void delete_instance() { delete d_instance; d_instance = 0; }
62 
63  CmrCache();
64  CmrCache(const CmrCache &src);
65 
66  static std::string getCacheDirFromConfig();
67  static std::string getCachePrefixFromConfig();
68  static unsigned long getCacheSizeFromConfig();
69 
70 protected:
71  CmrCache(const std::string &cache_dir, const std::string &prefix, unsigned long long size);
72 
73 public:
74  static const std::string DIR_KEY;
75  static const std::string PREFIX_KEY;
76  static const std::string SIZE_KEY;
77 
78  static CmrCache *get_instance(const std::string &cache_dir, const std::string &prefix, unsigned long long size);
79  static CmrCache *get_instance();
80 
81  virtual std::string get_cache_file_name(const std::string &src, bool mangle=true);
82  inline std::string get_hash(const std::string &name);
83 
84  virtual ~CmrCache() { }
85 };
86 
87 } /* namespace cmr */
88 
89 #endif /* MODULES_CMR_MODULE_CMRCACHE_H_ */
cmr::CmrCache::get_hash
std::string get_hash(const std::string &name)
Definition: CmrCache.cc:208
BESFileLockingCache
Implementation of a caching mechanism for compressed data.
Definition: BESFileLockingCache.h:85
cmr::CmrCache
A cache for content accessed via the CMR.
Definition: CmrCache.h:56
cmr::CmrCache::get_cache_file_name
virtual std::string get_cache_file_name(const std::string &src, bool mangle=true)
Definition: CmrCache.cc:215
cmr::CmrCache::get_instance
static CmrCache * get_instance()
Definition: CmrCache.cc:174