comparison Core/Cache/MemoryCache.h @ 3557:4d809b2e1141

better cache toolbox: MemoryObjectCache
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 04 Nov 2019 15:18:38 +0100
parents 4e43e67f8ecf
children 94f4a18a79cc
comparison
equal deleted inserted replaced
3556:87940f7156e0 3557:4d809b2e1141
37 #include "LeastRecentlyUsedIndex.h" 37 #include "LeastRecentlyUsedIndex.h"
38 #include "ICachePageProvider.h" 38 #include "ICachePageProvider.h"
39 39
40 namespace Orthanc 40 namespace Orthanc
41 { 41 {
42 /** 42 namespace Deprecated
43 * WARNING: This class is NOT thread-safe.
44 **/
45 class MemoryCache
46 { 43 {
47 private: 44 /**
48 struct Page 45 * WARNING: This class is NOT thread-safe.
46 **/
47 class MemoryCache
49 { 48 {
50 std::string id_; 49 private:
51 std::auto_ptr<IDynamicObject> content_; 50 struct Page
51 {
52 std::string id_;
53 std::auto_ptr<IDynamicObject> content_;
54 };
55
56 ICachePageProvider& provider_;
57 size_t cacheSize_;
58 LeastRecentlyUsedIndex<std::string, Page*> index_;
59
60 Page& Load(const std::string& id);
61
62 public:
63 MemoryCache(ICachePageProvider& provider,
64 size_t cacheSize);
65
66 ~MemoryCache();
67
68 IDynamicObject& Access(const std::string& id);
69
70 void Invalidate(const std::string& id);
52 }; 71 };
53 72 }
54 ICachePageProvider& provider_;
55 size_t cacheSize_;
56 LeastRecentlyUsedIndex<std::string, Page*> index_;
57
58 Page& Load(const std::string& id);
59
60 public:
61 MemoryCache(ICachePageProvider& provider,
62 size_t cacheSize);
63
64 ~MemoryCache();
65
66 IDynamicObject& Access(const std::string& id);
67
68 void Invalidate(const std::string& id);
69 };
70 } 73 }