Memcached
Memcached service 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
username
: Set the username for authentication.password
: Set the password for authentication.endpoint
: Set the network address of memcached serverdefault_ttl
: Set the ttl for memcached service.
You can refer to [MemcachedBuilder
]'s docs for more information
Example
Via Builder
use anyhow::Result;
use opendal::services::Memcached;
use opendal::Operator;
#[tokio::main]
async fn main() -> Result<()> {
// create memcached backend builder
let mut builder = Memcached::default();
builder.endpoint("tcp://127.0.0.1:11211");
// if you enable authentication, set username and password for authentication
// builder.username("admin");
// builder.password("password");
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("endpoint".to_string(), "tcp://127.0.0.1:11211".to_string());
let op: Operator = Operator::via_map(Scheme::Memcached, map)?;
Ok(())
}
import { Operator } from "opendal";
async function main() {
const op = new Operator("memcached", {
endpoint: "tcp://127.0.0.1:11211",
});
}
import opendal
op = opendal.Operator("memcached",
endpoint="tcp://127.0.0.1:11211",
)