- Notifications
You must be signed in to change notification settings - Fork69
An async client for Valkey and Redis
License
Apache-2.0, MIT licenses found
Licenses found
Apache-2.0
LICENSE-APACHEMIT
LICENSE-MITNotificationsYou must be signed in to change notification settings
aembke/fred.rs
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
An async client for Valkey and Redis
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.
- RESP2 and RESP3 protocol modes.
- Clustered, centralized, and sentinel server deployments.
- TLS via
native-tls
orrustls
. - Unix sockets.
- Automatic reconnection interfaces.
- Publish-Subscribe and keyspace events interfaces.
- A round-robin client pooling interface.
- A round-robin replica routing interface.
- Built-in mocking interfaces.
- Luascriptsorfunctions.
- Transactions
- Pipelining
- Client Tracking
- Automatic pipelining
- Zero-copy frame parsing
- Tracing
See the build features for more information.
Name | Default | Description |
---|---|---|
transactions | x | Enable aTransaction interface. |
enable-native-tls | Enable TLS support vianative-tls. | |
enable-rustls | Enable TLS support viarustls with the default crypto backend features. | |
enable-rustls-ring | Enable TLS support viarustls and the ring crypto backend. | |
vendored-openssl | Enable thenative-tls/vendored feature. | |
metrics | Enable the metrics interface to track overall latency, network latency, and request/response sizes. | |
full-tracing | Enable fulltracing support. This can emit a lot of data. | |
partial-tracing | Enable partialtracing support, only emitting traces for top level commands and network latency. | |
blocking-encoding | Use 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-errors | Enable an interface for callers to customize the types of errors that should automatically trigger reconnection logic. | |
monitor | Enable an interface for running theMONITOR command. | |
sentinel-client | Enable an interface for communicating directly with Sentinel nodes. This is not necessary to use normal Redis clients behind a sentinel layer. | |
sentinel-auth | Enable an interface for using different authentication credentials to sentinel nodes. | |
subscriber-client | Enable a subscriber client interface that manages channel subscription state for callers. | |
serde-json | Enable an interface to automatically convert Redis types to JSON viaserde-json . | |
mocks | Enable a mocking layer interface that can be used to intercept and process commands in tests. | |
dns | Enable an interface that allows callers to override the DNS lookup logic. | |
replicas | Enable an interface that routes commands to replica nodes. | |
default-nil-types | Enable a looser parsing interface fornil values. | |
sha-1 | Enable an interface for hashing Lua scripts. | |
unix-sockets | Enable Unix socket support. | |
credential-provider | Enable an interface that can dynamically load auth credentials at runtime. | |
dynamic-pool | Enable an client pooling interface that can scale based on usage metrics. | |
tcp-user-timeouts | Enable an interface that allows callers to setTCP_USER_TIMEOUT on TCP sockets. | |
glommio | Enable experimentalGlommio support. |
The command interfaces have many functions and compile times can add up quickly. Interface featuresbegin withi-
and control which public interfaces are built.
Name | Default | Description |
---|---|---|
i-all | Enable the interfaces described in this table. | |
i-std | x | Enable the common data structure interfaces (lists, sets, streams, keys, etc). |
i-acl | Enable the ACL command interface. | |
i-client | Enable the CLIENT command interface. | |
i-cluster | Enable the CLUSTER command interface. | |
i-config | Enable the CONFIG command interface. | |
i-geo | Enable the GEO command interface. | |
i-hashes | Enable the hashes (HGET, etc) command interface. | |
i-hyperloglog | Enable the hyperloglog command interface. | |
i-keys | Enable the main keys (GET, SET, etc) command interface. | |
i-lists | Enable the lists (LPUSH, etc) command interface. | |
i-scripts | Enable the scripting command interfaces. | |
i-memory | Enable the MEMORY command interfaces. | |
i-pubsub | Enable the publish-subscribe command interfaces. | |
i-server | Enable the server control (SHUTDOWN, BGSAVE, etc) interfaces. | |
i-sets | Enable the sets (SADD, etc) interface. | |
i-sorted-sets | Enable the sorted sets (ZADD, etc) interface. | |
i-slowlog | Enable the SLOWLOG interface. | |
i-streams | Enable the streams (XADD, etc) interface. | |
i-tracking | Enable 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.
Features currently specific to Redis, typically versions >=7.2.5:
Name | Default | Description |
---|---|---|
i-time-series | Enable aRedis Timeseries interface. | |
i-redis-json | Enable aRedisJSON interface. | |
i-redisearch | Enable aRediSearch interface. | |
i-redis-stack | Enable theRedis Stack interfaces (i-redis-json ,i-time-series , etc). | |
i-hexpire | Enable the hashmap expiration interface (HEXPIRE ,HTTL , etc). |
Name | Default | Description |
---|---|---|
debug-ids | Enable a global counter used to differentiate commands in logs. | |
network-logs | Enable 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-APACHEMIT
LICENSE-MITUh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.