Skip to main content

Crate ringline_momento

Crate ringline_momento 

Source
Expand description

ringline-native Momento cache client for use inside the ringline async runtime.

This client uses the Momento protosocket protocol (length-delimited protobuf over TLS) for high-performance cache operations. It is fully multiplexed: multiple requests can be in-flight on a single connection, correlated by message ID.

§Example

use ringline::ConnCtx;
use ringline_momento::{Client, Credential};

async fn example() -> Result<(), ringline_momento::Error> {
    let credential = Credential::from_env()?;
    let mut client = Client::connect(&credential).await?;

    // Sequential convenience API
    client.set("my-cache", b"key", b"value", 60_000).await?;
    let value = client.get("my-cache", b"key").await?;

    // Multiplexed fire/recv API
    let id1 = client.fire_get("my-cache", b"key1", 0)?;
    let id2 = client.fire_get("my-cache", b"key2", 0)?;
    let op1 = client.recv().await?;
    let op2 = client.recv().await?;

    Ok(())
}

§Copy Semantics

PathCopiesMechanism
Recv (values)0with_bytes() + CacheResponse::decode_bytes(). Values are Bytes::slice() references into the accumulator — zero allocation, O(1) refcount.
Send (requests)1Single-pass encode_into() writes all protobuf nesting levels directly into one buffer. Then send_nowait() copies into the send pool. Namespace is O(1) clone when pre-set via set_namespace() / ClientBuilder::namespace().

All Momento connections use TLS, which adds encryption copies on the send path regardless of the encoding strategy. SendGuard (zero-copy send) cannot help here since TLS must read plaintext and write ciphertext.

Re-exports§

pub use credential::Credential;
pub use error::Error;
pub use pool::Pool;
pub use pool::PoolConfig;

Modules§

credential
Momento credential handling.
error
Error types for the Momento client.
pool
Connection pool for ringline-momento.
proto
Minimal protobuf encoding/decoding for Momento cache messages.

Structs§

Client
A ringline-native Momento cache client wrapping a single connection.
ClientBuilder
Builder for creating a Client with per-request callbacks and metrics.
ClientMetrics
Built-in histogram-based metrics, available when the metrics feature is enabled.
CommandResult
Result metadata for a completed command, passed to the on_result callback.
RequestId
Identifies an in-flight request.

Enums§

CommandType
The type of cache command that completed.
CompletedOp
A completed cache operation.

Constants§

MAX_RECV_SKIPS
Maximum number of consecutive responses with unmatched message_ids the recv / authenticate loops will skip before poisoning the connection. The skip behavior exists so a single stale or duplicate response doesn’t drop every in-flight op, but unbounded skipping lets a misbehaving server starve our in-flight ops indefinitely by streaming junk. 256 unmatched messages in a row is far past any reasonable retransmit / race window.