Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

An async client for Valkey and Redis

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
NotificationsYou must be signed in to change notification settings

aembke/fred.rs

Repository files navigation

LicenseLicenseCircleCICrates.ioAPI docs

An async client for Valkey and Redis

Example

use fred::prelude::*;#[tokio::main]asyncfnmain() ->Result<(),Error>{let config =Config::from_url("redis://localhost:6379/1")?;let client =Builder::from_config(config).with_connection_config(|config|{      config.connection_timeout =Duration::from_secs(5);      config.tcp =TcpConfig{nodelay:Some(true),        ..Default::default()};}).build()?;  client.init().await?;  client.on_error(|(error, server)|asyncmove{println!("{:?}: Connection error: {:?}", server, error);Ok(())});// convert responses to many common Rust typeslet foo:Option<String> = client.get("foo").await?;assert!(foo.is_none());  client.set("foo","bar",None,None,false).await?;// or use turbofish to declare response typesprintln!("Foo: {:?}", client.get::<String, _>("foo").await?);  client.quit().await?;Ok(())}

See theexamples for more.

Features

See the build features for more information.

Client Features

NameDefaultDescription
transactionsxEnable aTransaction interface.
enable-native-tlsEnable TLS support vianative-tls.
enable-rustlsEnable TLS support viarustls with the default crypto backend features.
enable-rustls-ringEnable TLS support viarustls and the ring crypto backend.
vendored-opensslEnable thenative-tls/vendored feature.
metricsEnable the metrics interface to track overall latency, network latency, and request/response sizes.
full-tracingEnable fulltracing support. This can emit a lot of data.
partial-tracingEnable partialtracing support, only emitting traces for top level commands and network latency.
blocking-encodingUse a blocking task for encoding or decoding frames. This can be useful for clients that send or receive large payloads, but requires a multi-thread Tokio runtime.
custom-reconnect-errorsEnable an interface for callers to customize the types of errors that should automatically trigger reconnection logic.
monitorEnable an interface for running theMONITOR command.
sentinel-clientEnable an interface for communicating directly with Sentinel nodes. This is not necessary to use normal Redis clients behind a sentinel layer.
sentinel-authEnable an interface for using different authentication credentials to sentinel nodes.
subscriber-clientEnable a subscriber client interface that manages channel subscription state for callers.
serde-jsonEnable an interface to automatically convert Redis types to JSON viaserde-json.
mocksEnable a mocking layer interface that can be used to intercept and process commands in tests.
dnsEnable an interface that allows callers to override the DNS lookup logic.
replicasEnable an interface that routes commands to replica nodes.
default-nil-typesEnable a looser parsing interface fornil values.
sha-1Enable an interface for hashing Lua scripts.
unix-socketsEnable Unix socket support.
credential-providerEnable an interface that can dynamically load auth credentials at runtime.
dynamic-poolEnable an client pooling interface that can scale based on usage metrics.
tcp-user-timeoutsEnable an interface that allows callers to setTCP_USER_TIMEOUT on TCP sockets.
glommioEnable experimentalGlommio support.

Interface Features

The command interfaces have many functions and compile times can add up quickly. Interface featuresbegin withi- and control which public interfaces are built.

NameDefaultDescription
i-allEnable the interfaces described in this table.
i-stdxEnable the common data structure interfaces (lists, sets, streams, keys, etc).
i-aclEnable the ACL command interface.
i-clientEnable the CLIENT command interface.
i-clusterEnable the CLUSTER command interface.
i-configEnable the CONFIG command interface.
i-geoEnable the GEO command interface.
i-hashesEnable the hashes (HGET, etc) command interface.
i-hyperloglogEnable the hyperloglog command interface.
i-keysEnable the main keys (GET, SET, etc) command interface.
i-listsEnable the lists (LPUSH, etc) command interface.
i-scriptsEnable the scripting command interfaces.
i-memoryEnable the MEMORY command interfaces.
i-pubsubEnable the publish-subscribe command interfaces.
i-serverEnable the server control (SHUTDOWN, BGSAVE, etc) interfaces.
i-setsEnable the sets (SADD, etc) interface.
i-sorted-setsEnable the sorted sets (ZADD, etc) interface.
i-slowlogEnable the SLOWLOG interface.
i-streamsEnable the streams (XADD, etc) interface.
i-trackingEnable aclient tracking interface.

If a specific high level command function is not supported callers can use thecustom function as a workaround untilthe higher level interface is added. See thecustomexample for more info.

Redis Features

Features currently specific to Redis, typically versions >=7.2.5:

NameDefaultDescription
i-time-seriesEnable aRedis Timeseries interface.
i-redis-jsonEnable aRedisJSON interface.
i-redisearchEnable aRediSearch interface.
i-redis-stackEnable theRedis Stack interfaces (i-redis-json,i-time-series, etc).
i-hexpireEnable the hashmap expiration interface (HEXPIRE,HTTL, etc).

Debugging Features

NameDefaultDescription
debug-idsEnable a global counter used to differentiate commands in logs.
network-logsEnable additional TRACE logs for all frames on all sockets.

About

An async client for Valkey and Redis

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Contributors36

Languages


[8]ページ先頭

©2009-2025 Movatter.jp