virtual int initialize(const DoutPrefixProvider* dpp) = 0;
virtual int put(const DoutPrefixProvider* dpp, const std::string& key, const bufferlist& bl, uint64_t len, const rgw::sal::Attrs& attrs, optional_yield y) = 0;
virtual int get(const DoutPrefixProvider* dpp, const std::string& key, off_t offset, uint64_t len, bufferlist& bl, rgw::sal::Attrs& attrs, optional_yield y) = 0;
- virtual int del(const DoutPrefixProvider* dpp, const std::string& key, optional_yield y) = 0;
virtual rgw::AioResultList get_async (const DoutPrefixProvider* dpp, optional_yield y, rgw::Aio* aio, const std::string& key, off_t ofs, uint64_t len, uint64_t cost, uint64_t id) = 0;
virtual rgw::AioResultList put_async(const DoutPrefixProvider* dpp, optional_yield y, rgw::Aio* aio, const std::string& key, const bufferlist& bl, uint64_t len, const rgw::sal::Attrs& attrs, uint64_t cost, uint64_t id) = 0;
virtual int append_data(const DoutPrefixProvider* dpp, const::std::string& key, const bufferlist& bl_data, optional_yield y) = 0;
return 0;
}
-int RedisDriver::del(const DoutPrefixProvider* dpp, const std::string& key, optional_yield y)
-{
- std::string entry = partition_info.location + key;
- response<int> resp;
-
- try {
- boost::system::error_code ec;
- response<
- ignore_t,
- ignore_t,
- ignore_t,
- response<std::optional<int>, std::optional<int>>
- > resp;
- request req;
- req.push("MULTI");
- req.push("HSTRLEN", entry, "data");
- req.push("DEL", entry);
- req.push("EXEC");
-
- redis_exec(conn, ec, req, resp, y);
-
- if (ec) {
- ldpp_dout(dpp, 0) << "RedisDriver::" << __func__ << "(): ERROR: " << ec.what() << dendl;
- return -ec.value();
- }
-
- this->free_space += std::get<0>(std::get<3>(resp).value()).value().value();
- } catch (std::exception &e) {
- ldpp_dout(dpp, 0) << "RedisDriver::" << __func__ << "(): ERROR: " << e.what() << dendl;
- return -EINVAL;
- }
-
- return 0;
-}
-
int RedisDriver::append_data(const DoutPrefixProvider* dpp, const::std::string& key, const bufferlist& bl_data, optional_yield y)
{
std::string value = "";
int RedisDriver::delete_data(const DoutPrefixProvider* dpp, const::std::string& key, optional_yield y)
{
std::string entry = partition_info.location + key;
+ response<int> resp;
try {
boost::system::error_code ec;
- request req;
response<
ignore_t,
ignore_t,
ignore_t,
response<std::optional<int>, std::optional<int>>
> resp;
+ request req;
req.push("MULTI");
req.push("HSTRLEN", entry, "data");
- req.push("HDEL", entry, "data");
+ req.push("DEL", entry);
req.push("EXEC");
redis_exec(conn, ec, req, resp, y);
return -EINVAL;
}
- return 0;
+ return 0;
}
int RedisDriver::rename(const DoutPrefixProvider* dpp, const::std::string& oldKey, const::std::string& newKey, optional_yield y) {
const rgw::sal::Attrs& attrs, uint64_t cost, uint64_t id) override;
virtual int get(const DoutPrefixProvider* dpp, const std::string& key, off_t offset, uint64_t len, bufferlist& bl, rgw::sal::Attrs& attrs, optional_yield y) override;
virtual rgw::AioResultList get_async(const DoutPrefixProvider* dpp, optional_yield y, rgw::Aio* aio, const std::string& key, off_t ofs, uint64_t len, uint64_t cost, uint64_t id) override;
- virtual int del(const DoutPrefixProvider* dpp, const std::string& key, optional_yield y) override;
virtual int append_data(const DoutPrefixProvider* dpp, const::std::string& key, const bufferlist& bl_data, optional_yield y) override;
virtual int delete_data(const DoutPrefixProvider* dpp, const::std::string& key, optional_yield y) override;
virtual int rename(const DoutPrefixProvider* dpp, const::std::string& oldKey, const::std::string& newKey, optional_yield y) override;
virtual int initialize(const DoutPrefixProvider* dpp) override;
virtual int put(const DoutPrefixProvider* dpp, const std::string& key, const bufferlist& bl, uint64_t len, const rgw::sal::Attrs& attrs, optional_yield y) override;
virtual int get(const DoutPrefixProvider* dpp, const std::string& key, off_t offset, uint64_t len, bufferlist& bl, rgw::sal::Attrs& attrs, optional_yield y) override;
- virtual int del(const DoutPrefixProvider* dpp, const std::string& key, optional_yield y) override { return -1; } // TODO: implement
virtual rgw::AioResultList get_async (const DoutPrefixProvider* dpp, optional_yield y, rgw::Aio* aio, const std::string& key, off_t ofs, uint64_t len, uint64_t cost, uint64_t id) override;
virtual rgw::AioResultList put_async(const DoutPrefixProvider* dpp, optional_yield y, rgw::Aio* aio, const std::string& key, const bufferlist& bl, uint64_t len, const rgw::sal::Attrs& attrs, uint64_t cost, uint64_t id) override;
virtual int append_data(const DoutPrefixProvider* dpp, const::std::string& key, const bufferlist& bl_data, optional_yield y) override;
io.run();
}
-TEST_F(RedisDriverFixture, DelYield)
+TEST_F(RedisDriverFixture, DeleteDataYield)
{
boost::asio::spawn(io, [this] (boost::asio::yield_context yield) {
ASSERT_EQ(0, cacheDriver->put(env->dpp, "testName", bl, bl.length(), attrs, yield));
EXPECT_EQ(std::get<0>(resp).value(), 1);
}
- ASSERT_EQ(0, cacheDriver->del(env->dpp, "testName", yield));
+ ASSERT_EQ(0, cacheDriver->delete_data(env->dpp, "testName", yield));
cacheDriver->shutdown();
{
io.run();
}
-TEST_F(RedisDriverFixture, DeleteDataYield)
-{
- boost::asio::spawn(io, [this] (boost::asio::yield_context yield) {
- ASSERT_EQ(0, cacheDriver->put(env->dpp, "testName", bl, bl.length(), attrs, yield));
-
- {
- boost::system::error_code ec;
- request req;
- req.push("HEXISTS", "RedisCache/testName", "data");
- response<int> resp;
-
- conn->async_exec(req, resp, yield[ec]);
-
- ASSERT_EQ((bool)ec, false);
- EXPECT_EQ(std::get<0>(resp).value(), 1);
- }
-
- ASSERT_EQ(0, cacheDriver->delete_data(env->dpp, "testName", yield));
- cacheDriver->shutdown();
-
- {
- boost::system::error_code ec;
- request req;
- req.push("HEXISTS", "RedisCache/testName", "data");
- req.push("FLUSHALL");
- response<int, boost::redis::ignore_t> resp;
-
- conn->async_exec(req, resp, yield[ec]);
-
- ASSERT_EQ((bool)ec, false);
- EXPECT_EQ(std::get<0>(resp).value(), 0);
- }
-
- conn->cancel();
- }, rethrow);
-
- io.run();
-}
-
TEST_F(RedisDriverFixture, RenameYield)
{
boost::asio::spawn(io, [this] (boost::asio::yield_context yield) {