bes  Updated for version 3.20.6
GatewayCache.h
1 // -*- mode: c++; c-basic-offset:4 -*-
2 
3 // This file is part of gateway_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  * GatewayCache.h
27  *
28  * Created on: Oct 2, 2015
29  * Author: ndp
30  */
31 
32 #ifndef MODULES_GATEWAY_MODULE_GATEWAYCACHE_H_
33 #define MODULES_GATEWAY_MODULE_GATEWAYCACHE_H_
34 
35 #include "BESFileLockingCache.h"
36 
37 namespace gateway
38 {
39 
58 {
59 private:
60  static bool d_enabled;
61  static GatewayCache * d_instance;
62  static void delete_instance() { delete d_instance; d_instance = 0; }
63 
64  GatewayCache();
65  GatewayCache(const GatewayCache &src);
66 
67  static std::string getCacheDirFromConfig();
68  static std::string getCachePrefixFromConfig();
69  static unsigned long getCacheSizeFromConfig();
70 
71 protected:
72  GatewayCache(const std::string &cache_dir, const std::string &prefix, unsigned long long size);
73 
74 public:
75  static const std::string DIR_KEY;
76  static const std::string PREFIX_KEY;
77  static const std::string SIZE_KEY;
78 
79  static GatewayCache *get_instance(const std::string &cache_dir, const std::string &prefix, unsigned long long size);
80  static GatewayCache *get_instance();
81 
82  virtual ~GatewayCache() { }
83 };
84 
85 } /* namespace gateway */
86 
87 #endif /* MODULES_GATEWAY_MODULE_GATEWAYCACHE_H_ */
gateway::GatewayCache::get_instance
static GatewayCache * get_instance()
Definition: GatewayCache.cc:169
gateway::GatewayCache
A cache for data files accessed using the Gateway.
Definition: GatewayCache.h:57
BESFileLockingCache
Implementation of a caching mechanism for compressed data.
Definition: BESFileLockingCache.h:85