Hazelcast C++ Client
NearCache.h
1 /*
2  * Copyright (c) 2008-2017, 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>
50  class DataStructureAdapter;
51  }
52 
53  namespace nearcache {
54  class HAZELCAST_API BaseNearCache
55  : public spi::InitializingObject, public util::Clearable, public util::Destroyable {
56  };
57 
67  template<typename K, typename V>
68  class NearCache : public BaseNearCache {
69  public:
73  static boost::shared_ptr<V> NULL_OBJECT;
74 
75  virtual ~NearCache() {
76  }
77 
78  void initialize() {
79  assert(0);
80  }
81 
86 
91 
97  virtual const std::string &getName() const {
98  assert(0);
99  return *(new std::string(""));
100  }
101 
108  virtual boost::shared_ptr<V> get(const boost::shared_ptr<K> &key) {
109  assert(0);
110  return boost::shared_ptr<V>();
111  }
112 
119  virtual void put(const boost::shared_ptr<K> &key, const boost::shared_ptr<V> &value) {
120  assert(0);
121  }
122 
129  virtual void put(const boost::shared_ptr<K> &key,
130  const boost::shared_ptr<serialization::pimpl::Data> &value) {
131  assert(0);
132  }
133 
139  virtual bool remove(const boost::shared_ptr<K> &key) {
140  assert(0);
141  return false;
142  }
143 
147  virtual bool isInvalidatedOnChange() const {
148  assert(0);
149  return false;
150  }
151 
157  virtual const config::InMemoryFormat getInMemoryFormat() const {
158  assert(0);
159  return config::BINARY;
160  }
161 
168 
174  virtual int size() const {
175  assert(0);
176  return -1;
177  }
178  };
179 
180  template<typename K, typename V>
181  boost::shared_ptr<V> NearCache<K, V>::NULL_OBJECT = boost::shared_ptr<V>(new V());
182  }
183  }
184  }
185 }
186 
187 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
188 #pragma warning(pop)
189 #endif
190 
191 #endif /* HAZELCAST_CLIENT_INTERNAL_NEARCACHE_NEARCACHE_H_ */
192 
static const int DEFAULT_EXPIRATION_TASK_DELAY_IN_SECONDS
Default expiration task delay time as seconds.
Definition: NearCache.h:90
virtual const std::string & getName() const
Gets the name of the this com.hazelcast.cache.impl.nearcache.NearCache instance.
Definition: NearCache.h:97
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:129
virtual const config::InMemoryFormat getInMemoryFormat() const
Gets the com.hazelcast.config.InMemoryFormat of the storage for internal records. ...
Definition: NearCache.h:157
virtual int size() const
Gets the count of stored records.
Definition: NearCache.h:174
NearCache is the contract point to store keys and values in underlying com.hazelcast.cache.impl.nearcache.NearCacheRecordStore.
Definition: NearCache.h:68
static const int DEFAULT_EXPIRATION_TASK_INITIAL_DELAY_IN_SECONDS
Default expiration task initial delay time as seconds.
Definition: NearCache.h:85
virtual monitor::NearCacheStats & getNearCacheStats()=0
Get the com.hazelcast.monitor.NearCacheStats instance to monitor this store.
static boost::shared_ptr< V > NULL_OBJECT
NULL Object.
Definition: NearCache.h:73
virtual bool isInvalidatedOnChange() const
Definition: NearCache.h:147
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:119
Definition: MapEntryView.h:32
Definition: NearCacheStats.h:45