Redis
Redis services support.
Capabilities
This service can be used to:
- stat
- read
- write
- create_dir
- delete
- copy
- rename
-
list -
presign - blocking
Configuration
root
: Set the working directory ofOpenDAL
endpoint
: Set the network address of redis servercluster_endpoints
: Set the network address of redis cluster server. This parameter is mutually exclusive with theendpoint
parameter.username
: Set the username of Redispassword
: Set the password for authenticationdb
: Set the DB of redis
You can refer to [RedisBuilder
]'s docs for more information
Example
Via Builder
use anyhow::Result;
use opendal::services::Redis;
use opendal::Operator;
#[tokio::main]
async fn main() -> Result<()> {
let mut builder = Redis::default();
// this will build a Operator accessing Redis which runs on tcp://localhost:6379
let op: Operator = Operator::new(builder)?.finish();
Ok(())
}
Via Config
- Rust
- Node.js
- Python
use anyhow::Result;
use opendal::Operator;
use opendal::Scheme;
use std::collections::HashMap;
#[tokio::main]
async fn main() -> Result<()> {
let mut map = HashMap::new();
map.insert("root".to_string(), "/path/to/dir".to_string());
map.insert("endpoint".to_string(), "tcp://127.0.0.1:6379".to_string());
map.insert("username".to_string(), "your_username".to_string());
map.insert("password".to_string(), "your_password".to_string());
map.insert("db".to_string(), "0".to_string());
let op: Operator = Operator::via_map(Scheme::Redis, map)?;
Ok(())
}
import { Operator } from "opendal";
async function main() {
const op = new Operator("redis", {
root: "/path/to/dir",
endpoint: "tcp://127.0.0.1:6379",
username: "your_username",
password: "your_password",
db: "0",
});
}
import opendal
op = opendal.Operator("redis",
root="/path/to/dir",
endpoint="tcp://127.0.0.1:6379",
username="your_username",
password="your_password",
db="0",
)