Hazelcast C++ Client
NearCache.h
1 /*
2  * Copyright (c) 2008-2018, 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 #ifndef HAZELCAST_CLIENT_INTERNAL_NEARCACHE_NEARCACHE_H_
17 #define HAZELCAST_CLIENT_INTERNAL_NEARCACHE_NEARCACHE_H_
18 
19 #include <string>
20 #include <assert.h>
21 
22 #include <boost/shared_ptr.hpp>
23 
24 #include "hazelcast/client/config/InMemoryFormat.h"
25 #include "hazelcast/util/HazelcastDll.h"
26 #include "hazelcast/util/Clearable.h"
27 #include "hazelcast/util/Destroyable.h"
28 #include "hazelcast/client/spi/InitializingObject.h"
29 
30 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
31 #pragma warning(push)
32 #pragma warning(disable: 4251) //for dll export
33 #endif
34 
35 namespace hazelcast {
36  namespace client {
37  namespace serialization {
38  namespace pimpl {
39  class Data;
40  }
41  }
42 
43  namespace monitor {
44  class NearCacheStats;
45  }
46 
47  namespace internal {
48  namespace adapter {
49  template<typename K, typename V>
51  }
52 
53  namespace nearcache {
54  class HAZELCAST_API BaseNearCache
55  : public spi::InitializingObject, public util::Clearable, public util::Destroyable {
56  public:
62  virtual monitor::NearCacheStats &getNearCacheStats() = 0;
63 
69  virtual const std::string &getName() const = 0;
70  };
71 
81  template<typename K, typename V>
82  class NearCache : public BaseNearCache {
83  public:
87  static boost::shared_ptr<V> NULL_OBJECT;
88 
89  virtual ~NearCache() {
90  }
91 
92  void initialize() {
93  assert(0);
94  }
95 
100 
105 
112  virtual boost::shared_ptr<V> get(const boost::shared_ptr<K> &key) {
113  assert(0);
114  return boost::shared_ptr<V>();
115  }
116 
123  virtual void put(const boost::shared_ptr<K> &key, const boost::shared_ptr<V> &value) {
124  assert(0);
125  }
126 
133  virtual void put(const boost::shared_ptr<K> &key,
134  const boost::shared_ptr<serialization::pimpl::Data> &value) {
135  assert(0);
136  }
137 
144  virtual bool invalidate(const boost::shared_ptr<K> &key) {
145  assert(0);
146  return false;
147  }
148 
152  virtual bool isInvalidatedOnChange() const {
153  assert(0);
154  return false;
155  }
156 
162  virtual const client::config::InMemoryFormat getInMemoryFormat() const {
163  assert(0);
164  return client::config::BINARY;
165  }
166 
172  virtual int size() const {
173  assert(0);
174  return -1;
175  }
176  };
177 
178  template<typename K, typename V>
179  boost::shared_ptr<V> NearCache<K, V>::NULL_OBJECT = boost::shared_ptr<V>(new V());
180  }
181  }
182  }
183 }
184 
185 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
186 #pragma warning(pop)
187 #endif
188 
189 #endif /* HAZELCAST_CLIENT_INTERNAL_NEARCACHE_NEARCACHE_H_ */
190 
virtual int size() const
Gets the count of stored records.
Definition: NearCache.h:172
static const int DEFAULT_EXPIRATION_TASK_DELAY_IN_SECONDS
Default expiration task delay time as seconds.
Definition: NearCache.h:104
virtual void put(const boost::shared_ptr< K > &key, const boost::shared_ptr< serialization::pimpl::Data > &value)
Puts (associates) a value with the given key.
Definition: NearCache.h:133
virtual bool invalidate(const boost::shared_ptr< K > &key)
Removes the value associated with the given.
Definition: NearCache.h:144
NearCache is the contract point to store keys and values in underlying com.hazelcast.cache.impl.nearcache.NearCacheRecordStore.
Definition: NearCache.h:82
static const int DEFAULT_EXPIRATION_TASK_INITIAL_DELAY_IN_SECONDS
Default expiration task initial delay time as seconds.
Definition: NearCache.h:99
static boost::shared_ptr< V > NULL_OBJECT
NULL Object.
Definition: NearCache.h:87
virtual void put(const boost::shared_ptr< K > &key, const boost::shared_ptr< V > &value)
Puts (associates) a value with the given key.
Definition: NearCache.h:123
virtual bool isInvalidatedOnChange() const
Definition: NearCache.h:152
virtual const client::config::InMemoryFormat getInMemoryFormat() const
Gets the com.hazelcast.config.InMemoryFormat of the storage for internal records. ...
Definition: NearCache.h:162
PN (Positive-Negative) CRDT counter.
Definition: MapEntryView.h:32
Definition: NearCacheStats.h:45