redis-rs | Redis library for rust | Command Line Interface library
kandi X-RAY | redis-rs Summary
kandi X-RAY | redis-rs Summary
Redis library for rust
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of redis-rs
redis-rs Key Features
redis-rs Examples and Code Snippets
Community Discussions
Trending Discussions on redis-rs
QUESTION
I am currently using redis-rs to set up a simple redis interface, a part of this has me spawning a thread that has a redis subscriber in a loop checking for jobs, a minimal code example is
...ANSWER
Answered 2021-Jan-01 at 20:26You are creating a connection as a local variable in the function and then trying to use a reference to it in a thread. The thread will need that reference after the function call is finished, but the variable will be dropped at the end of the function call.
I guess the reason that you create the connection outside of thread is so that you can handle the error before the thread is spawned.
What you can do instead, since redis::Connection
is Send
, is to move the connection into the thread and then call as_pubsub()
inside the thread. This way you are not referencing something from outside the thread.
QUESTION
I'm trying to use the Rust redis client in the asynchronous multiplexed mode, with tokio as the async runtime, and dynamic number of futures to join.
I had success using future::join3
on a constant number of futures, but I want to multiplex many more commands (the specific size should not have to be known in compile-time, but even that would be an improvement).
This is the working example when using future::join3
; The example correctly prints
Ok(Some("PONG")) Ok(Some("PONG")) Ok(Some("PONG"))
Cargo.toml
ANSWER
Answered 2020-Dec-21 at 16:50This should work, I just extended the lifetime of redis_connection
.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install redis-rs
Rust is installed and managed by the rustup tool. Rust has a 6-week rapid release process and supports a great number of platforms, so there are many builds of Rust available at any time. Please refer rust-lang.org for more information.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page