Skip to content

Latest commit

 

History

History
32 lines (26 loc) · 846 Bytes

compression.md

File metadata and controls

32 lines (26 loc) · 846 Bytes

Compression

By default the driver does not use any compression on connections.
It's possible to specify a preferred compression algorithm.
The driver will try using it, but if the database doesn't support it, it will fall back to no compression.

Available compression algorithms:

  • Snappy
  • LZ4

An example enabling Snappy compression algorithm:

# extern crate scylla;
# extern crate tokio;
use scylla::{Session, SessionBuilder};
use scylla::connection::Compression;
use std::error::Error;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let uri = std::env::var("SCYLLA_URI")
        .unwrap_or_else(|_| "127.0.0.1:9042".to_string());

    let session: Session = SessionBuilder::new()
        .known_node(uri)
        .compression(Some(Compression::Snappy))
        .build()
        .await?;

    Ok(())
}