Hazelcast C++ Client
Hazelcast C++ Client Library
eviction_config.h
1 /*
2  * Copyright (c) 2008-2022, Hazelcast, Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 
18 #include <string>
19 #include <ostream>
20 
21 #include "hazelcast/client/config/eviction_policy.h"
22 #include "eviction_strategy_type.h"
23 #include "eviction_strategy_type.h"
24 
25 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
26 #pragma warning(push)
27 #pragma warning(disable : 4251) // for dll export
28 #endif
29 
30 namespace hazelcast {
31 namespace client {
32 namespace config {
37 class HAZELCAST_API eviction_config
38 {
39 public:
40  ~eviction_config() = default;
41 
46  {
51  ENTRY_COUNT
52  /* TODO,
53  *
54  * Policy based on maximum used native memory in megabytes per data
55  structure (map, cache etc)
56  * on each Hazelcast instance
57 
58  USED_NATIVE_MEMORY_SIZE,
59  *
60  * Policy based on maximum used native memory percentage per data
61  structure (map, cache etc)
62  * on each Hazelcast instance
63 
64  USED_NATIVE_MEMORY_PERCENTAGE,
65  *
66  * Policy based on minimum free native memory in megabytes per Hazelcast
67  instance
68 
69  FREE_NATIVE_MEMORY_SIZE,
70  *
71  * Policy based on minimum free native memory percentage per Hazelcast
72  instance
73 
74  FREE_NATIVE_MEMORY_PERCENTAGE*/
75  };
76 
80  static constexpr int32_t DEFAULT_MAX_ENTRY_COUNT = INT32_MAX;
81 
85  static constexpr max_size_policy DEFAULT_MAX_SIZE_POLICY =
86  max_size_policy::ENTRY_COUNT;
87 
91  static constexpr eviction_policy DEFAULT_EVICTION_POLICY =
92  eviction_policy::LRU;
93 
95 
96  int32_t get_size() const;
97 
98  eviction_config& set_size(int32_t size);
99 
100  max_size_policy get_maximum_size_policy() const;
101 
102  eviction_config& set_maximum_size_policy(
104 
105  eviction_policy get_eviction_policy() const;
106 
107  eviction_config& set_eviction_policy(eviction_policy policy);
108 
109  eviction_strategy_type get_eviction_strategy_type() const;
110 
111  friend std::ostream HAZELCAST_API& operator<<(
112  std::ostream& out,
113  const eviction_config& config);
114 
115 protected:
116  int32_t size_;
117  max_size_policy max_size_policy_;
118  eviction_policy eviction_policy_;
119 };
120 
121 } // namespace config
122 } // namespace client
123 } // namespace hazelcast
124 
125 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
126 #pragma warning(pop)
127 #endif