boost_redis 1.4.2
A redis client library
write.hpp
1/* Copyright (c) 2018-2022 Marcelo Zimbres Silva (mzimbres@gmail.com)
2 *
3 * Distributed under the Boost Software License, Version 1.0. (See
4 * accompanying file LICENSE.txt)
5 */
6
7#ifndef BOOST_REDIS_WRITE_HPP
8#define BOOST_REDIS_WRITE_HPP
9
10#include <boost/asio/write.hpp>
11#include <boost/redis/request.hpp>
12
13namespace boost::redis::detail {
14
21template<class SyncWriteStream>
22auto write(SyncWriteStream& stream, request const& req)
23{
24 return asio::write(stream, asio::buffer(req.payload()));
25}
26
27template<class SyncWriteStream>
28auto write(SyncWriteStream& stream, request const& req, system::error_code& ec)
29{
30 return asio::write(stream, asio::buffer(req.payload()), ec);
31}
32
40template<
41 class AsyncWriteStream,
42 class CompletionToken = asio::default_completion_token_t<typename AsyncWriteStream::executor_type>
43 >
45 AsyncWriteStream& stream,
46 request const& req,
47 CompletionToken&& token =
48 asio::default_completion_token_t<typename AsyncWriteStream::executor_type>{})
49{
50 return asio::async_write(stream, asio::buffer(req.payload()), token);
51}
52
53} // boost::redis::detail
54
55#endif // BOOST_REDIS_WRITE_HPP
Creates Redis requests.
Definition: request.hpp:46
auto async_write(AsyncWriteStream &stream, request const &req, CompletionToken &&token=asio::default_completion_token_t< typename AsyncWriteStream::executor_type >{})
Writes a request asynchronously.
Definition: write.hpp:44
auto write(SyncWriteStream &stream, request const &req)
Writes a request synchronously.
Definition: write.hpp:22