Module opendal::services::memcached

source ·
Expand description

Memcached support for OpenDAL

Configuration

  • root: Set the working directory of OpenDAL
  • endpoint: Set the network address of memcached server
  • default_ttl: Set the ttl for memcached service.

You can refer to Builder’s docs for more information

Environment

  • OPENDAL_MEMCACHED_ROOT optional
  • OPENDAL_MEMCACHED_ENDPOINT optional

Example

Initiate via environment variables:

Set environment correctly:

export OPENDAL_MEMCACHED_ENDPOINT=tcp://example.com
export OPENDAL_MEMCACHED_ROOT=/path/to/dir
use anyhow::Result;
use opendal::Object;
use opendal::Operator;
use opendal::Scheme;

#[tokio::main]
async fn main() -> Result<()> {
    let op = Operator::from_env(Scheme::Memcached);

    // create an object handler to start operation on redis!

    let _op: Object = op.object("hello_redis!");

    Ok(())
}

Via Builder

use anyhow::Result;
use opendal::services::memcached;
use opendal::Object;
use opendal::Operator;

#[tokio::main]
async fn main() -> Result<()> {
    let mut builder = memcached::Builder::default();

    builder.endpoint("tcp://127.0.0.1:11211")

    let op: Operator = Operator::new(builder.build());
    let _: Object = op.object("test_file");
    Ok(())
}

Structs

Memcached backend builder