Skip to content

[QUESTION] Abandon a pipeline after exec has been invoked #585

Open
@jbrezina

Description

@jbrezina

Describe the problem
I have the code which is called in a loop and I need to use the connection pool every iteration. If the single iteration does not finish within the specified time span I need to abandon the results and I'm not sure how to do that.
pipeline destructor returns the connection to the pool, but in the next iteration I get an error with access violation. I cannot use discard as it also results in access violation.
Is there a safe way how to abandon the in-progress commands on connections from the connection pool?

std::future<void> task;
{
	auto pipeline{ _redis->pipeline(false) };

	task = std::async(std::launch::async, [&]() {
		// filling the pipe with data
		pipeline.set(...);

		auto replies{ pipeline.exec() };
	});

	if (const auto status{ task.wait_for(std::chrono::milliseconds(500)) };
		status == std::future_status::timeout) {
		// abandon the pipeline if it didn't finish within the required time span
		//pipeline.discard();
	}
}

Environment:

  • OS: Windows 11
  • Compiler: Visual Studio MSVC Version 17.10.4
  • hiredis version: v1.2.0
  • redis-plus-plus version: 1.3.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions