simple_redis 0.1.4

Simple redis client.
Documentation

simple_redis

crates.io Build Status Build status Crates.io Crates.io

Simple redis client for rust.

Overview

This library provides a very basic, simple API for the most common redis operations. While not as comprehensive or flexiable as redis-rs, it does provide a simpler api for most common use cases and operations as well as automatic internal connection handling. Connection validation is done before every operation invocation, so there is no need to create/release or validate connections before running any Redis operation. However, this comes at a small performance cost of PING operation to the redis server. This library is still in initial development stage and many more features will come soon.

Usage

In order to use this library, you need to first include the crate as follows:

extern crate simple_redis;

Afterwards create a redis client using a connection string:

match simple_redis::create("redis://127.0.0.1:6379/") {
    Ok(mut client) =>  println!("Created Redis Client"),
    Err(error) => println!("Unable to create Redis client: {}", error)
}

Once you have a redis client, you can invoke any of the available commands directly or use the run_command function to invoke operations that were not implemented by the library.

match client.set("my_key", "my_value") {
    Err(error) => println!("Unable to set value in Redis: {}", error),
    _ => println!("Value set in Redis")
}

match client.get("my_key") {
    Ok(value) => println!("Read value from Redis: {}", value),
    Err(error) => println!("Unable to get value from Redis: {}", error)
}

/// run some command that is not built in the library
match client.run_command::<String>("ECHO", vec!["testing"]) {
    Ok(value) => assert_eq!(value, "testing"),
    _ => panic!("test error"),
}

Installation

In order to use this library, just add it as a dependency:

[dependencies]
simple_redis = "*"

API Documentation

See full docs at: API Docs

Contributing

See contributing guide

Release History

Date Version Description
2017-06-02 v0.1.4 Initial release.

License

Developed by Sagie Gur-Ari and licensed under the Apache 2 open source license.