MCPcopy Create free account
hub / github.com/AliveToolkit/alive2 / Cache

Method Cache

cache/cache.cpp:91–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91Cache::Cache(unsigned port, bool allow_version_mismatch) {
92 const char *hostname = "127.0.0.1";
93 struct timeval timeout = {1, 500000}; // 1.5 seconds
94 ctx = redisConnectWithTimeout(hostname, port, timeout);
95 if (!ctx) {
96 cerr << "Can't allocate redis context\n";
97 exit(-1);
98 }
99 if (ctx->err) {
100 cerr << "Redis connection error: " << ctx->errstr << '\n';
101 exit(-1);
102 }
103 string version;
104 if (remote_get("Alive2_version", version, ctx)) {
105 if (version != util::alive_version) {
106 cerr << "Cache version mismatch!\n"
107 "This version of Alive2 is " << util::alive_version << "\n"
108 "But the cache was created by version " << version << '\n';
109 if (!allow_version_mismatch)
110 exit(-1);
111 }
112 } else {
113 remote_set("Alive2_version", util::alive_version, ctx);
114 }
115}
116
117Cache::~Cache() {
118 redisFree(ctx);

Callers

nothing calls this directly

Calls 2

remote_getFunction · 0.85
remote_setFunction · 0.85

Tested by

no test coverage detected