annotate OrthancFramework/Sources/FileStorage/StorageCache.h @ 4792:434843934307 storage-cache

Added a StorageCache in the StorageAccessor
author Alain Mazy <am@osimis.io>
date Thu, 30 Sep 2021 12:14:19 +0200
parents
children 7053502fbf97
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4792
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
1 /**
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
6 *
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public License
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
10 * the License, or (at your option) any later version.
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
11 *
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
15 * Lesser General Public License for more details.
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
16 *
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
18 * License along with this program. If not, see
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
19 * <http://www.gnu.org/licenses/>.
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
20 **/
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
21
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
22
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
23 #pragma once
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
24
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
25 #include "../Cache/MemoryStringCache.h"
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
26
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
27 #include "../Compatibility.h" // For ORTHANC_OVERRIDE
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
28
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
29 #include <boost/thread/mutex.hpp>
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
30 #include <map>
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
31
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
32 namespace Orthanc
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
33 {
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
34 /**
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
35 * Note: this class is thread safe
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
36 **/
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
37 class ORTHANC_PUBLIC StorageCache : public boost::noncopyable
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
38 {
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
39 MemoryStringCache cache_;
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
40 public:
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
41 void SetMaximumSize(size_t size);
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
42
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
43 void Add(const std::string& uuid,
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
44 FileContentType contentType,
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
45 const std::string& value);
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
46
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
47 void Add(const std::string& uuid,
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
48 FileContentType contentType,
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
49 const void* buffer,
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
50 size_t size);
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
51
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
52 void Invalidate(const std::string& uuid, FileContentType contentType);
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
53
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
54 bool Fetch(std::string& value,
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
55 const std::string& uuid,
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
56 FileContentType contentType);
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
57
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
58 };
434843934307 Added a StorageCache in the StorageAccessor
Alain Mazy <am@osimis.io>
parents:
diff changeset
59 }