Rust

memcached

Module

Cache adapters over the Memcached text protocol: Memcached and Hazelcast.

Contents

use utopia_cache::Hazelcast;
Rust
pub struct Hazelcast<K = Json>

Entries in Hazelcast through its Memcached endpoint: one item per key holding an Envelope (JSON by default), as the Redis adapters store it. Hazelcast cannot flush, so Adapter::flush returns false.

Rust
use php_std::types::Value;
use utopia_cache::{Adapter, Hazelcast, MemcachedClient};

let cache = Hazelcast::new(MemcachedClient::new("localhost", 5701));
cache.save("greeting", &Value::from("hello"), "", 0).await?;
assert_eq!(cache.load("greeting", 60, "").await?, Some(Value::from("hello")));
Compiles in CI; needs a running service to execute.
use utopia_cache::Memcached;
Rust
pub struct Memcached

Entries in Memcached: one item per key holding the entry's data and the time it was written. Hashes are ignored.

Rust
use php_std::types::Value;
use utopia_cache::{Adapter, Memcached, MemcachedClient};

let cache = Memcached::new(MemcachedClient::new("localhost", 11211));
cache.save("greeting", &Value::from("hello"), "", 0).await?;
assert_eq!(cache.load("greeting", 60, "").await?, Some(Value::from("hello")));
Compiles in CI; needs a running service to execute.
use utopia_cache::MemcachedClient;
Rust
pub struct MemcachedClient

A connection to one Memcached-protocol server (Memcached, or Hazelcast with its Memcached endpoint), reconnecting after a failure.