Hazelcast C++ Client
Hazelcast C++ Client Library
near_cache_config.h
1 /*
2  * Copyright (c) 2008-2021, 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 "hazelcast/client/config/in_memory_format.h"
19 #include "hazelcast/client/config/eviction_config.h"
20 
21 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
22 #pragma warning(push)
23 #pragma warning(disable: 4251) //for dll export
24 #endif
25 
26 namespace hazelcast {
27  namespace client {
28  namespace config {
33  class HAZELCAST_API near_cache_config {
34  public:
38  static constexpr int32_t DEFAULT_TTL_SECONDS = 0;
39 
43  static constexpr int32_t DEFAULT_MAX_IDLE_SECONDS = 0;
44 
48  static constexpr in_memory_format DEFAULT_MEMORY_FORMAT = in_memory_format::BINARY;
49 
58 
62  CACHE
63  };
64 
66 
67  near_cache_config(const std::string &cache_name);
68 
69  near_cache_config(const std::string &cache_name, in_memory_format memory_format);
70 
71  near_cache_config(int32_t time_to_live_seconds, int32_t max_idle_seconds, bool invalidate_on_change,
72  in_memory_format in_memory_format, const eviction_config &evict_config);
73 
74  virtual ~near_cache_config() = default;
75 
81  const std::string &get_name() const;
82 
89  near_cache_config &set_name(const std::string &name);
90 
97  int32_t get_time_to_live_seconds() const;
98 
107  near_cache_config &set_time_to_live_seconds(int32_t time_to_live_seconds);
108 
117  int32_t get_max_idle_seconds() const;
118 
129  near_cache_config &set_max_idle_seconds(int32_t max_idle_seconds);
130 
139  bool is_invalidate_on_change() const;
140 
151  near_cache_config &set_invalidate_on_change(bool invalidate_on_change);
152 
161  const in_memory_format &get_in_memory_format() const;
162 
172  virtual near_cache_config &set_in_memory_format(const in_memory_format &in_memory_format);
173 
180  bool is_cache_local_entries() const;
181 
189  near_cache_config &set_cache_local_entries(bool cache_local_entries);
190 
191  const local_update_policy &get_local_update_policy() const;
192 
193  near_cache_config &set_local_update_policy(const local_update_policy &local_update_policy);
194 
200  eviction_config &get_eviction_config();
201 
208  near_cache_config &set_eviction_config(const eviction_config &eviction_config);
209 
210  friend std::ostream HAZELCAST_API &operator<<(std::ostream &out, const near_cache_config &cache_config);
211  private:
212  std::string name_;
213 
214  int32_t time_to_live_seconds_;
215  int32_t max_idle_seconds_;
216 
217  in_memory_format in_memory_format_;
218 
219  local_update_policy local_update_policy_;
220 
221  bool invalidate_on_change_;
222  bool cache_local_entries_;
223 
232  eviction_config eviction_config_;
233 
234  int32_t calculate_max_size(int32_t max_size);
235  };
236 
237  }
238  }
239 }
240 
241 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
242 #pragma warning(pop)
243 #endif
244 
245 
Contains the configuration for a Near Cache.