# redis-rs guide (Rust)

```json metadata
{
  "title": "redis-rs guide (Rust)",
  "description": "Connect your Rust application to a Redis database",
  "categories": ["docs","develop","stack","oss","rs","rc","oss","kubernetes","clients"],
  "tableOfContents": {"sections":[{"id":"install","title":"Install"},{"id":"connect","title":"Connect"},{"id":"more-information","title":"More information"}]}
}
```














[`redis-rs`](https://github.com/redis-rs/redis-rs) is the [Rust](https://www.rust-lang.org/) client for Redis.
The sections below explain how to install `redis-rs` and connect your application to a Redis database.

Although we provide basic documentation for `redis-rs`, it is a third-party
client library and is not developed or supported directly by Redis.


`redis-rs` requires a running Redis server. See [here](https://redis.io/docs/latest/operate/oss_and_stack/install/) for Redis Open Source installation instructions.

## Install

To use the synchronous API, add the `redis` crate as a dependency in your
`Cargo.toml` file:

```toml
[dependencies]
redis = "0.32.5"
```

If you want to use the asynchronous API, you should also enable either
[`tokio`](https://tokio.rs/) or [`smol`](https://crates.io/crates/smol)
as your async platform:

```toml
[dependencies]
# if you use tokio
tokio = { version = "1.32.0", features = ["full"] }
redis = { version = "0.32.5", features = ["tokio-comp"] }

# if you use smol
smol = "2.0.2"
redis = { version = "0.32.5", features = ["smol-comp"] }
```

## Connect

Start by importing the `Commands` or `AsyncCommands` trait from the `redis` crate:




The following example shows the simplest way to connect to a Redis server:




After connecting, you can test the connection by  storing and retrieving
a simple [string](https://redis.io/docs/latest/develop/data-types/strings):




You can also easily store and retrieve a [hash](https://redis.io/docs/latest/develop/data-types/hashes):




## More information

See the [`redis-rs`](https://docs.rs/redis/latest/redis/) documentation
and the [GitHub repository](https://github.com/redis-rs/redis-rs) for more
information and examples.
