Skip to main content

Crate glide

Crate glide 

Source
Expand description

§Valkey GLIDE for Rust (glide)

crates.io docs.rs CI Rust

A first-class, native Rust client for Valkey and Redis OSS, built directly on the shared glide-core engine that powers the official GLIDE clients for Python, Java, Node, and Go.

Because glide-core is itself written in Rust, this wrapper links to it directly — no FFI, no socket bridge — making it the thinnest and fastest GLIDE binding.

§Highlights

  • Async first — GlideClient (standalone) and GlideClusterClient (cluster) built on Tokio.
  • Blocking API — a sync layer mirrors the async surface for non-async code (enabled by the default sync feature).
  • Broad command coverage — typed methods across strings, generic/key, hash, list, set, sorted-set, HyperLogLog, bitmap, geo, stream, scripting, connection- and server-management, plus batches/transactions.
  • custom_command escape hatch — run any command (with optional cluster routing) even where a typed wrapper is not provided, guaranteeing 100% functional coverage.
  • Batching — pipe() pipelines and MULTI/EXEC transactions, executed typed via query_async (zero extra payload copies) or with GLIDE execution controls (PipelineOptions: per-call timeout and pipeline retry strategy) via exec.
  • Dynamic authentication — rotate the connection password at runtime with update_connection_password, or use AWS IAM auth (ElastiCache / MemoryDB) via ServerCredentials::iam.
  • Runtime Pub/Sub — subscribe/psubscribe/ssubscribe (and the matching unsubscribes) in addition to connect-time subscriptions; messages arrive via get_pubsub_message.
  • OpenTelemetry — export traces and metrics via the glide::telemetry module (gRPC / HTTP / file exporters).
  • Feature parity with the Python GLIDE wrapper as the baseline for the API surface.

§Documentation

GLIDE concepts — cluster routing, batching, the PubSub model, multi-slot command handling, and OpenTelemetry — are shared with the official clients and documented at glide.valkey.io; this client is built on the same core, so those concepts apply here unchanged. For Rust-specific architecture see DESIGN.md.

§Supported Engine Versions

The compatibility target matches GLIDE — see the Supported Engine Versions table. It is tested on Linux (x86_64 and aarch64). Other platforms (e.g. macOS) should work wherever glide-core builds, but are not tested yet.

§Installation

§Prerequisites

  • Rust — Install via rustup.
  • A running Valkey (or Redis OSS) server to connect to — e.g. valkey-server locally, docker run -p 6379:6379 valkey/valkey, or an ElastiCache/MemoryDB endpoint.

§Add the dependency

The package is named valkey-glide and the library is imported as glide. The async client is built on Tokio, so you will also need a Tokio runtime:

cargo add valkey-glide
cargo add tokio --features rt-multi-thread,macros

The first build compiles glide-core and its dependency tree, so it takes a few minutes; subsequent builds are incremental.

§Quick start (async)

use glide::{AsyncCommands, GlideClient, GlideClientConfiguration};

#[tokio::main]
async fn main() -> glide::ValkeyResult<()> {
    let config = GlideClientConfiguration::with_address("localhost", 6379);
    let client = GlideClient::connect(config).await.expect("connect");

    client.set::<_, _, ()>("hello", "world").await?;
    let value: Option<String> = client.get("hello").await?;
    assert_eq!(value.as_deref(), Some("world"));
    Ok(())
}

§Quick start (sync)

use glide::sync::SyncGlideClient;
use glide::{Commands, GlideClientConfiguration};

fn main() -> glide::ValkeyResult<()> {
    let client = SyncGlideClient::connect(
        GlideClientConfiguration::with_address("localhost", 6379),
    ).expect("connect");
    client.set::<_, _, ()>("hello", "world")?;
    let value: Option<String> = client.get("hello")?;
    assert_eq!(value.as_deref(), Some("world"));
    Ok(())
}

§Cluster & routing

use glide::{GlideClusterClient, GlideClusterClientConfiguration, Route, CustomCommand};

let client = GlideClusterClient::connect(
    GlideClusterClientConfiguration::with_address("localhost", 7000),
).await?;

// Broadcast PING to all primaries.
client.custom_command_with_route(&["PING"], Route::AllPrimaries).await?;

§Migrating from redis-rs

GLIDE’s command API mirrors redis-rs 1.7.0, so most call sites migrate with only import and type-name changes. See migration.md for more details.

§Getting Help

  • GitHub Issues: Check the existing issues first; if your question or problem isn’t covered, open a new issue.
  • Valkey Slack: For questions about Valkey or GLIDE in general, join the Valkey Slack.

§Contributing

Contributions are welcome — bug reports, feature requests, and pull requests. See the Contributing Guidelines to get started and DEVELOPER.md for the development workflow.

§License

Licensed under the Apache License, Version 2.0. See the LICENSE for the full text.

Re-exports§

pub use types::IntegerReplyOrNoOp;
pub use types::ValueType;
pub use value::FromValkeyValue;
pub use value::ValkeyValue;
pub use value::ValkeyVerbatimFormat;
pub use write::ToSingleValkeyArg;
pub use write::ToValkeyArgs;
pub use write::ValkeyNumericBehavior;
pub use write::ValkeyWrite;
pub use error::GlideError;
pub use routes::Route;
pub use routes::SlotType;
pub use client::ClusterScanCursor;
pub use client::GlideClient;
pub use client::GlideClusterClient;
pub use client::PipelineExt;
pub use client::PubSubMessage;
pub use client::PubSubMessageKind;
pub use config::BackoffStrategy;
pub use config::ClientIdentity;
pub use config::GlideClientConfiguration;
pub use config::GlideClusterClientConfiguration;
pub use config::IamAuthConfig;
pub use config::NodeAddress;
pub use config::NodeDiscoveryMode;
pub use config::PeriodicChecks;
pub use config::ProtocolVersion;
pub use config::PubSubChannelMode;
pub use config::PubSubSubscriptions;
pub use config::ReadFrom;
pub use config::ServerCredentials;
pub use config::ServiceType;
pub use config::TlsConfig;
pub use cmd::Cmd;
pub use cmd::cmd;
pub use commands::core::AsyncCommands;
pub use commands::core::AsyncTypedCommands;
pub use executor::CustomCommand;
pub use commands::core::Commands;
pub use commands::core::TypedCommands;
pub use commands::options::ClientPauseMode;
pub use commands::options::CopyOptions;
pub use commands::options::Direction;
pub use commands::options::ExistenceCheck;
pub use commands::options::ExpireOption;
pub use commands::options::Expiry;
pub use commands::options::FieldExistenceCheck;
pub use commands::options::FlushAllOptions;
pub use commands::options::FlushDbOptions;
pub use commands::options::FunctionFlushOptions;
pub use commands::options::FunctionRestorePolicy;
pub use commands::options::HashFieldExpirationOptions;
pub use commands::options::Limit;
pub use commands::options::LposOptions;
pub use commands::options::MigrateOptions;
pub use commands::options::ObjectType;
pub use commands::options::OrderBy;
pub use commands::options::RestoreOptions;
pub use commands::options::SetExpiry;
pub use commands::options::SetOptions;
pub use commands::options::ValueComparison;
pub use commands::bitmap::BitEncoding;
pub use commands::bitmap::BitFieldOffset;
pub use commands::bitmap::BitFieldSubcommand;
pub use commands::bitmap::BitOverflow;
pub use commands::bitmap::BitmapIndexType;
pub use commands::geo::GeoCoord;
pub use commands::geo::GeoSearchOptions;
pub use commands::geo::GeoSearchResult;
pub use commands::geo::GeoSearchShape;
pub use commands::geo::GeoSearchStoreOptions;
pub use commands::geo::GeoUnit;
pub use commands::sorted_set::AggregationType;
pub use commands::sorted_set::LexBound;
pub use commands::sorted_set::ScoreBound;
pub use commands::stream::StreamAddOptions;
pub use commands::stream::StreamAutoClaimOptions;
pub use commands::stream::StreamAutoClaimReply;
pub use commands::stream::StreamClaimOptions;
pub use commands::stream::StreamClaimReply;
pub use commands::stream::StreamEntry;
pub use commands::stream::StreamGroupCreateOptions;
pub use commands::stream::StreamId;
pub use commands::stream::StreamInfoConsumer;
pub use commands::stream::StreamInfoConsumersReply;
pub use commands::stream::StreamInfoGroup;
pub use commands::stream::StreamInfoGroupsReply;
pub use commands::stream::StreamInfoStreamReply;
pub use commands::stream::StreamKey;
pub use commands::stream::StreamMaxlen;
pub use commands::stream::StreamPendingCountReply;
pub use commands::stream::StreamPendingData;
pub use commands::stream::StreamPendingId;
pub use commands::stream::StreamPendingReply;
pub use commands::stream::StreamRangeReply;
pub use commands::stream::StreamReadGroupOptions;
pub use commands::stream::StreamReadOptions;
pub use commands::stream::StreamReadReply;
pub use commands::stream::StreamTrimOptions;
pub use commands::stream::StreamTrimStrategy;
pub use commands::stream::StreamTrimmingMode;
pub use commands::stream::XPendingEntry;
pub use commands::scan::ScanIter;
pub use commands::scan::SyncScanIter;
pub use script::Script;
pub use script::ScriptInvocation;
pub use pipeline::Pipeline;
pub use pipeline::pipe;
pub use pipeline_options::PipelineOptions;
pub use commands::prelude::*;

Modules§

client
The async GLIDE clients.
cmd
GLIDE’s owned command builder.
commands
Command families. Each submodule is an extension trait with a blanket impl over crate::executor::CommandExecutor, so every client gets every command.
config
Client configuration.
error
Error types for the GLIDE Rust client.
executor
The command dispatch trait.
pipeline
GLIDE’s owned pipeline / transaction builder.
pipeline_options
GLIDE execution options for crate::Pipelines.
routes
Request routing for cluster clients.
script
Lua script helper (Script): SHA-caching EVALSHA with EVAL fallback.
sync
Blocking (synchronous) clients.
telemetry
OpenTelemetry integration.
types
Typed reply types returned by crate::AsyncTypedCommands and crate::TypedCommands.
value
Valkey reply value types.
write
Valkey command argument encoding.

Structs§

BigInt
A big signed integer type.
Bytes
A cheaply cloneable and sliceable chunk of contiguous memory.

Type Aliases§

ValkeyFuture
The future returned by GLIDE async commands.
ValkeyResult
The result type for GLIDE sync operations.