Hazelcast C++ Client
Hazelcast C++ Client Library
near_cache_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 "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 {
35 public:
39  static constexpr int32_t DEFAULT_TTL_SECONDS = 0;
40 
44  static constexpr int32_t DEFAULT_MAX_IDLE_SECONDS = 0;
45 
49  static constexpr in_memory_format DEFAULT_MEMORY_FORMAT =
50  in_memory_format::BINARY;
51 
56  {
61 
65  CACHE
66  };
67 
69 
70  near_cache_config(const std::string& cache_name);
71 
72  near_cache_config(const std::string& cache_name,
73  in_memory_format memory_format);
74 
75  near_cache_config(int32_t time_to_live_seconds,
76  int32_t max_idle_seconds,
77  bool invalidate_on_change,
78  in_memory_format in_memory_format,
79  const eviction_config& evict_config);
80 
81  virtual ~near_cache_config() = default;
82 
88  const std::string& get_name() const;
89 
96  near_cache_config& set_name(const std::string& name);
97 
106  int32_t get_time_to_live_seconds() const;
107 
118  near_cache_config& set_time_to_live_seconds(int32_t time_to_live_seconds);
119 
128  int32_t get_max_idle_seconds() const;
129 
140  near_cache_config& set_max_idle_seconds(int32_t max_idle_seconds);
141 
152  bool is_invalidate_on_change() const;
153 
166  near_cache_config& set_invalidate_on_change(bool invalidate_on_change);
167 
176  const in_memory_format& get_in_memory_format() const;
177 
187  virtual near_cache_config& set_in_memory_format(
188  const in_memory_format& in_memory_format);
189 
197  bool is_cache_local_entries() const;
198 
207  near_cache_config& set_cache_local_entries(bool cache_local_entries);
208 
209  const local_update_policy& get_local_update_policy() const;
210 
211  near_cache_config& set_local_update_policy(
212  const local_update_policy& local_update_policy);
213 
219  eviction_config& get_eviction_config();
220 
227  near_cache_config& set_eviction_config(
229 
230  friend std::ostream HAZELCAST_API& operator<<(
231  std::ostream& out,
232  const near_cache_config& cache_config);
233 
234 private:
235  std::string name_;
236 
237  int32_t time_to_live_seconds_;
238  int32_t max_idle_seconds_;
239 
240  in_memory_format in_memory_format_;
241 
242  local_update_policy local_update_policy_;
243 
244  bool invalidate_on_change_;
245  bool cache_local_entries_;
246 
255  eviction_config eviction_config_;
256 
257  int32_t calculate_max_size(int32_t max_size);
258 };
259 
260 } // namespace config
261 } // namespace client
262 } // namespace hazelcast
263 
264 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
265 #pragma warning(pop)
266 #endif
Contains the configuration for a Near Cache.