Mercurial > hg > orthanc-stone
comparison Framework/Deprecated/Toolbox/BaseWebService.h @ 872:733c6db3e5a3 am-dev
limiting the size of the cache
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Mon, 01 Jul 2019 13:36:51 +0200 |
parents | c35e98d22764 |
children | 200b4e0dddfc |
comparison
equal
deleted
inserted
replaced
863:23701fbf228e | 872:733c6db3e5a3 |
---|---|
23 | 23 |
24 #include "IWebService.h" | 24 #include "IWebService.h" |
25 | 25 |
26 #include <string> | 26 #include <string> |
27 #include <map> | 27 #include <map> |
28 #include <deque> | |
28 | 29 |
29 namespace Deprecated | 30 namespace Deprecated |
30 { | 31 { |
31 // This is an intermediate of IWebService that implements some caching on | 32 // This is an intermediate of IWebService that implements some caching on |
32 // the HTTP GET requests | 33 // the HTTP GET requests |
79 }; | 80 }; |
80 protected: | 81 protected: |
81 class BaseWebServicePayload; | 82 class BaseWebServicePayload; |
82 | 83 |
83 bool cacheEnabled_; | 84 bool cacheEnabled_; |
84 std::map<std::string, boost::shared_ptr<CachedHttpRequestSuccessMessage> > cache_; // TODO: this is currently an infinite cache ! | 85 size_t cacheCurrentSize_; |
86 size_t cacheMaxSize_; | |
87 | |
88 typedef std::map<std::string, boost::shared_ptr<CachedHttpRequestSuccessMessage> > HttpCache; | |
89 HttpCache cache_; | |
90 std::deque<std::string> orderedCacheKeys_; | |
85 | 91 |
86 public: | 92 public: |
87 | 93 |
88 BaseWebService(OrthancStone::MessageBroker& broker) : | 94 BaseWebService(OrthancStone::MessageBroker& broker) : |
89 IWebService(broker), | 95 IWebService(broker), |
90 IObserver(broker), | 96 IObserver(broker), |
91 cacheEnabled_(true) | 97 cacheEnabled_(true), |
98 cacheCurrentSize_(0), | |
99 cacheMaxSize_(100*1024*1024) | |
92 { | 100 { |
93 } | 101 } |
94 | 102 |
95 virtual ~BaseWebService() | 103 virtual ~BaseWebService() |
96 { | 104 { |