forked from infinispan/cpp-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RemoteCacheManager.h
89 lines (71 loc) · 2.6 KB
/
RemoteCacheManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#ifndef ISPN_HOTROD_REMOTECACHEMANAGER_H
#define ISPN_HOTROD_REMOTECACHEMANAGER_H
#include "infinispan/hotrod/ImportExport.h"
#include "infinispan/hotrod/Handle.h"
#include "infinispan/hotrod/RemoteCache.h"
#include "hotrod/sys/BasicMarshaller.h"
#include <string>
#include <map>
namespace infinispan {
namespace hotrod {
class RemoteCacheManagerImpl;
class Configuration;
class HR_EXTERN RemoteCacheManager : public Handle<RemoteCacheManagerImpl>
{
public:
explicit RemoteCacheManager(bool start = true);
explicit RemoteCacheManager(
const std::map<std::string, std::string>& configuration,
bool start = true);
void start();
void stop();
bool isStarted();
// TODO: change to std::map?
const Configuration& getConfiguration();
template <class K, class V> RemoteCache<K, V> getCache(
bool forceReturnValue = false)
{
RemoteCache<K, V> rcache;
initCache(rcache, forceReturnValue);
rcache.keyMarshaller.reset(new sys::BasicMarshaller<K>());
rcache.valueMarshaller.reset(new sys::BasicMarshaller<V>());
return rcache;
}
template <class K, class V> RemoteCache<K, V> getCache(
const std::string& name, bool forceReturnValue = false)
{
RemoteCache<K, V> rcache;
initCache(rcache, name, forceReturnValue);
rcache.keyMarshaller.reset(new sys::BasicMarshaller<K>());
rcache.valueMarshaller.reset(new sys::BasicMarshaller<V>());
return rcache;
}
template <class K, class V> RemoteCache<K, V> getCache(
HR_SHARED_PTR<Marshaller<K> > km, HR_SHARED_PTR<Marshaller<V> > vm,
bool forceReturnValue = false)
{
RemoteCache<K, V> rcache;
initCache(rcache, forceReturnValue);
rcache.keyMarshaller = km;
rcache.valueMarshaller = vm;
return rcache;
}
template <class K, class V> RemoteCache<K, V> getCache(
HR_SHARED_PTR<Marshaller<K> > km, HR_SHARED_PTR<Marshaller<V> > vm,
const std::string& name, bool forceReturnValue = false)
{
RemoteCache<K, V> rcache;
initCache(rcache, name, forceReturnValue);
rcache.keyMarshaller = km;
rcache.valueMarshaller = vm;
return rcache;
}
private:
void initCache(RemoteCacheBase& cache, bool forceReturnValue);
void initCache(RemoteCacheBase& cache, const std::string& name, bool forceReturnValue);
// not implemented
RemoteCacheManager(const RemoteCacheManager&);
RemoteCacheManager operator=(const RemoteCacheManager&);
};
}} // namespace infinispan::hotrod
#endif /* ISPN_HOTROD_REMOTECACHEMANAGER_H */