comparison Plugin/Cache/CacheManager.h @ 0:02f7a0400a91

initial commit
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 25 Feb 2015 13:45:35 +0100
parents
children a6492d20b2a8
comparison
equal deleted inserted replaced
-1:000000000000 0:02f7a0400a91
1 /**
2 * Orthanc - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012-2015 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 *
6 * This program is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU Affero General Public License
8 * as published by the Free Software Foundation, either version 3 of
9 * the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 **/
19
20
21 #pragma once
22
23 #include "../../Orthanc/SQLite/Connection.h"
24 #include "../../Orthanc/FileStorage/FilesystemStorage.h"
25
26 namespace OrthancPlugins
27 {
28 class CacheManager : public boost::noncopyable
29 {
30 private:
31 struct PImpl;
32 boost::shared_ptr<PImpl> pimpl_;
33
34 class Bundle;
35 class BundleQuota;
36
37 typedef std::map<int, Bundle> Bundles;
38 typedef std::map<int, BundleQuota> BundleQuotas;
39
40 const BundleQuota& GetBundleQuota(int bundleIndex) const;
41
42 Bundle GetBundle(int bundleIndex) const;
43
44 void MakeRoom(Bundle& bundle,
45 std::list<std::string>& toRemove,
46 int bundleIndex,
47 const BundleQuota& quota);
48
49 void EnsureQuota(int bundleIndex,
50 const BundleQuota& quota);
51
52 void ReadBundleStatistics();
53
54 void Open();
55
56 bool LocateInCache(std::string& uuid,
57 uint64_t& size,
58 int bundle,
59 const std::string& item);
60
61 void SanityCheck(); // Only for debug
62
63
64 public:
65 CacheManager(Orthanc::SQLite::Connection& db,
66 Orthanc::FilesystemStorage& storage);
67
68 void SetSanityCheckEnabled(bool enabled);
69
70 void Clear();
71
72 void Clear(int bundle);
73
74 void SetBundleQuota(int bundle,
75 uint32_t maxCount,
76 uint64_t maxSpace);
77
78 void SetDefaultQuota(uint32_t maxCount,
79 uint64_t maxSpace);
80
81 bool IsCached(int bundle,
82 const std::string& item);
83
84 bool Access(std::string& content,
85 int bundle,
86 const std::string& item);
87
88 void Invalidate(int bundle,
89 const std::string& item);
90
91 void Store(int bundle,
92 const std::string& item,
93 const std::string& content);
94
95 };
96 }