TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
redisstore.h
1 /*
2  * Copyright (c) 2017-present, Facebook, Inc.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #pragma once
9 
10 #include "distributed.h"
11 #include "redisclient.h"
12 
13 #include <memory>
14 
15 namespace cpid {
16 
17 /**
18  * c10d::Store for rendez-vous backed by Redis.
19  *
20  * This is pretty much a copy of gloo's RedisStore:
21  * https://github.com/facebookincubator/gloo/blob/master/gloo/rendezvous/redis_store.cc
22  */
23 class RedisStore : public c10d::Store {
24  public:
25  RedisStore(std::string prefix, std::string_view host, int port);
26  virtual ~RedisStore();
27 
28  void set(std::string const& key, std::vector<uint8_t> const& value) override;
29  std::vector<uint8_t> get(std::string const& key) override;
30  int64_t add(std::string const& key, int64_t value) override;
31  bool check(std::vector<std::string> const& keys) override;
32  void wait(std::vector<std::string> const& keys) override;
33  void wait(
34  std::vector<std::string> const& keys,
35  std::chrono::milliseconds const& timeout) override;
36 
37  private:
38  // TODO Remove this once c10d::PrefixStore wraps by shared_ptr
39  std::string prefix_;
40  std::unique_ptr<RedisClient> redis_;
41  std::vector<std::string> setKeys_;
42 };
43 
44 } // namespace cpid
RedisStore(std::string prefix, std::string_view host, int port)
Definition: redisstore.cpp:21
bool check(std::vector< std::string > const &keys) override
Definition: redisstore.cpp:73
virtual ~RedisStore()
Definition: redisstore.cpp:26
int64_t add(std::string const &key, int64_t value) override
Definition: redisstore.cpp:68
void wait(std::vector< std::string > const &keys) override
Definition: redisstore.cpp:101
The TorchCraftAI training library.
Definition: batcher.cpp:15
Definition: c10d.h:15
c10d::Store for rendez-vous backed by Redis.
Definition: redisstore.h:23