#pragma once #include "binary-cache-store.hh" #include namespace Aws { namespace Client { class ClientConfiguration; } } namespace Aws { namespace S3 { class S3Client; } } namespace nix { class S3BinaryCacheStore : public BinaryCacheStore { private: std::string bucketName; ref config; ref client; public: S3BinaryCacheStore(std::shared_ptr localStore, const Path & secretKeyFile, const std::string & bucketName); void init() override; struct Stats { std::atomic put{0}; std::atomic putBytes{0}; std::atomic putTimeMs{0}; std::atomic get{0}; std::atomic getBytes{0}; std::atomic getTimeMs{0}; std::atomic head{0}; }; const Stats & getS3Stats(); bool isValidPath(const Path & storePath) override; private: Stats stats; ref makeConfig(); protected: bool fileExists(const std::string & path) override; void upsertFile(const std::string & path, const std::string & data) override; std::string getFile(const std::string & path) override; }; }