[−][src]Function mini_redis::buffer
pub fn buffer(client: Client) -> Buffer
Create a new client request buffer
The Client
performs Redis commands directly on the TCP connection. Only a
single request may be in-flight at a given time and operations require
mutable access to the Client
handle. This prevents using a single Redis
connection from multiple Tokio tasks.
The strategy for dealing with this class of problem is to spawn a dedicated Tokio task to manage the Redis connection and using "message passing" to operate on the connection. Commands are pushed into a channel. The connection task pops commands off of the channel and applies them to the Redis connection. When the response is received, it is forwarded to the original requester.
The returned Buffer
handle may be cloned before passing the new handle to
separate tasks.