16 #ifndef HAZELCAST_CLIENT_INTERNAL_NEARCACHE_NEARCACHEMANAGER_H_ 17 #define HAZELCAST_CLIENT_INTERNAL_NEARCACHE_NEARCACHEMANAGER_H_ 22 #include "hazelcast/util/HazelcastDll.h" 23 #include "hazelcast/client/internal/nearcache/NearCache.h" 24 #include "hazelcast/client/internal/nearcache/impl/DefaultNearCache.h" 25 #include "hazelcast/client/serialization/pimpl/SerializationService.h" 27 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) 29 #pragma warning(disable: 4251) //for dll export 42 : serializationService(ss) {
54 template<
typename K,
typename V,
typename KS>
55 boost::shared_ptr<NearCache<KS, V> >
getNearCache(
const std::string &name) {
56 return boost::static_pointer_cast<
NearCache<KS, V> >(nearCacheMap.get(name));
71 template<
typename K,
typename V,
typename KS>
74 boost::shared_ptr<BaseNearCache> nearCache = nearCacheMap.get(name);
75 if (NULL == nearCache.get()) {
77 util::LockGuard guard(mutex);
78 nearCache = nearCacheMap.get(name);
79 if (NULL == nearCache.get()) {
80 nearCache = createNearCache<K, V, KS>(name, nearCacheConfig);
81 nearCache->initialize();
83 nearCacheMap.put(name, nearCache);
107 boost::shared_ptr<BaseNearCache> nearCache = nearCacheMap.get(name);
108 if (nearCache.get() != NULL) {
111 return nearCache.get() != NULL;
118 std::vector<boost::shared_ptr<BaseNearCache> > caches = nearCacheMap.values();
119 for (std::vector<boost::shared_ptr<BaseNearCache> >::iterator it = caches.begin();
120 it != caches.end(); ++it) {
132 boost::shared_ptr<BaseNearCache> nearCache = nearCacheMap.remove(name);
133 if (nearCache.get() != NULL) {
134 nearCache->destroy();
136 return nearCache.get() != NULL;
143 std::vector<boost::shared_ptr<BaseNearCache> > caches = nearCacheMap.values();
144 for (std::vector<boost::shared_ptr<BaseNearCache> >::iterator it = caches.begin();
145 it != caches.end(); ++it) {
150 template<
typename K,
typename V,
typename KS>
151 std::auto_ptr<NearCache<KS, V> > createNearCache(
153 return std::auto_ptr<NearCache<KS, V> >(
154 new impl::DefaultNearCache<K, V, KS>(
155 name, nearCacheConfig, serializationService));
158 serialization::pimpl::SerializationService &serializationService;
159 util::SynchronizedMap<std::string, BaseNearCache> nearCacheMap;
167 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) void destroyAllNearCaches()
Destroys all defined NearCache instances.
Definition: NearCacheManager.h:142
Contains the configuration for a Near Cache.
Definition: NearCacheConfig.h:44
bool destroyNearCache(const std::string &name)
Destroys NearCache instance associated with given.
Definition: NearCacheManager.h:131
NearCache is the contract point to store keys and values in underlying com.hazelcast.cache.impl.nearcache.NearCacheRecordStore.
Definition: NearCache.h:68
boost::shared_ptr< NearCache< KS, V > > getNearCache(const std::string &name)
Gets the NearCache instance associated with given.
Definition: NearCacheManager.h:55
NearCacheManager is the contract point to manage all existing NearCache instances.
Definition: NearCacheManager.h:39
void clearAllNearCaches()
Clears all defined NearCache instances.
Definition: NearCacheManager.h:117
Definition: MapEntryView.h:32
bool clearNearCache(const std::string &name)
Lists all existing NearCache instances.
Definition: NearCacheManager.h:106
boost::shared_ptr< NearCache< KS, V > > getOrCreateNearCache(const std::string &name, const config::NearCacheConfig< K, V > &nearCacheConfig)
Creates a new NearCache with given configurations or returns existing one.
Definition: NearCacheManager.h:72