5G-MAG Reference Tools - MBMS Middleware
CacheManagement.h
Go to the documentation of this file.
1 // 5G-MAG Reference Tools
2 // MBMS Middleware Process
3 //
4 // Copyright (C) 2021 Klaus Kühnhammer (Österreichische Rundfunksender GmbH & Co KG)
5 //
6 // Licensed under the License terms and conditions for use, reproduction, and
7 // distribution of 5G-MAG software (the “License”). You may not use this file
8 // except in compliance with the License. You may obtain a copy of the License at
9 // https://www.5g-mag.com/reference-tools. Unless required by applicable law or
10 // agreed to in writing, software distributed under the License is distributed on
11 // an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12 // or implied.
13 //
14 // See the License for the specific language governing permissions and limitations
15 // under the License.
16 //
17 
18 #pragma once
19 
20 #include <libconfig.h++>
21 #include <boost/asio.hpp>
22 #include "CacheItems.h"
23 
24 namespace MBMS_RT {
26  public:
27  CacheManagement(const libconfig::Config& cfg, boost::asio::io_service& io_service);
28  virtual ~CacheManagement() = default;
29 
30  void add_item(std::shared_ptr<CacheItem> item) {
31  _cache_items[item->content_location()] = item;
32  };
33  void remove_item(const std::string& location) { _cache_items.erase(location); };
34  const std::map<std::string, std::shared_ptr<CacheItem>>& item_map() const { return _cache_items; };
35 
37 
38 
39  private:
40  std::map<std::string, std::shared_ptr<CacheItem>> _cache_items;
41  unsigned _max_cache_size = 512;
42  unsigned _total_cache_size = 0;
43  unsigned _max_cache_file_age = 30;
44  boost::asio::io_service& _io_service;
45  };
46 }
CacheManagement(const libconfig::Config &cfg, boost::asio::io_service &io_service)
boost::asio::io_service & _io_service
virtual ~CacheManagement()=default
void remove_item(const std::string &location)
const std::map< std::string, std::shared_ptr< CacheItem > > & item_map() const
void add_item(std::shared_ptr< CacheItem > item)
std::map< std::string, std::shared_ptr< CacheItem > > _cache_items
static Config cfg
Global configuration object.
Definition: main.cpp:111