Redis re-implemented in Rust.

Related tags

Database rsedis
Overview

rsedis

Build Status Build status

Redis re-implemented in Rust.

Why?

To learn Rust.

Use Cases

rsedis does not rely on UNIX-specific features. Windows users can run it as a replacement of Redis.

rsedis uses multiple threads which may be more useful in machines with multiple cores.

Prerequisites

Rust nightly.

Current Status

See TODO.md.

License

Copyright (c) 2015, Sebastian Waisbrot All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Comments
  • Unable to compile

    Unable to compile

    Outputs the following error when I run cargo run

    Updating registry `https://github.com/rust-lang/crates.io-index`
     Downloading skiplist v0.2.4
     Downloading time v0.1.26
     Downloading gcc v0.3.8
       Compiling libc v0.1.8
       Compiling gcc v0.3.8
       Compiling response v0.1.0 (file:///Workspace/rustlang/git/rsedis)
       Compiling parser v0.1.0 (file:///Workspace/rustlang/git/rsedis)
    <std macros>:6:1: 6:32 error: the trait `core::convert::From<core::num::ParseFloatError>` is not implemented for the type `ParseError` [E0277]
    <std macros>:6 $ crate:: convert:: From:: from ( err ) ) } } )
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    <std macros>:1:1: 6:48 note: in expansion of try!
    parser/src/lib.rs:77:39: 77:66 note: expansion site
    <std macros>:6:1: 6:32 error: the trait `core::convert::From<core::num::ParseFloatError>` is not implemented for the type `ParseError` [E0277]
    <std macros>:6 $ crate:: convert:: From:: from ( err ) ) } } )
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    <std macros>:1:1: 6:48 note: in expansion of try!
    parser/src/lib.rs:79:35: 79:57 note: expansion site
    <std macros>:6:1: 6:32 error: the trait `core::convert::From<core::num::ParseFloatError>` is not implemented for the type `ParseError` [E0277]
    <std macros>:6 $ crate:: convert:: From:: from ( err ) ) } } )
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    <std macros>:1:1: 6:48 note: in expansion of try!
    parser/src/lib.rs:85:19: 85:41 note: expansion site
    error: aborting due to 3 previous errors
    Build failed, waiting for other jobs to finish...
    Could not compile `parser`.
    
    To learn more, run the command again with --verbose.
    
    opened by kingzbauer 6
  • using rustc 1.35.0

    using rustc 1.35.0

    cant run cargo build

    warning: unused import: libc::funcs::c95::ctype::isprint

    compiling parser v0.1.0 ...... rsedis/parser error[E0554]..... skiplist.0.2.10/src/lib.rs:26:35

    opened by hiqbn 5
  • Cannot split off at a nonexistent index

    Cannot split off at a nonexistent index

    I am learning rust and the source code of rsedis is a good teaching material.But I found a BUG:

      pub fn ltrim(&mut self, _start: i64, _stop: i64) -> Result<(), OperationError> {
            let list = match *self {
                ValueList::Data(ref mut list) => {
                    let len = list.len();
                    let start = match normalize_position(_start, len) {
                        Ok(i) => i,
                        Err(g) => if !g { 0 } else {
                            list.split_off(len);
                            len
                        },
                    };
                    let stop = match normalize_position(_stop, len) {
                        Ok(i) => i,
                        Err(g) => if !g {
                            list.split_off(len);
                            0
                        } else { len },
                    };
                    list.split_off(stop + 1);
                    list.split_off(start)
                }
            };
            *self = ValueList::Data(list);
            Ok(())
        }
    

    This is a function of the struct ValueList in database/src/list.rs. If _stop argument equal or greater than len , the value of stop will be len and stop + 1 will out of range. If stop less than len and start greater than stop + 1 , the program will panic.

    opened by wlsnx 3
  • Clean up code, fix clippy warnings, fix general coding style to be more

    Clean up code, fix clippy warnings, fix general coding style to be more "rustic"

    So I'm forking this library as a base to add a Redis-compatible API to my own database backend, and I thought I'd split out my own general fixes for efficiency and coding style into their own PR so that I could merge them back upstream. I'll explain some of the more common fixes:

    • &String/&Vec<T> are unnecessary for the API and just add an extra pointer indirection, you should use &str/&[T]
    • format!(..).to_owned() is unnecessary, format! already returns a String so you're creating a String, then copying it to a new allocation and dropping the first String.
    • format!("{}", foo) is strictly slower than foo.to_string() since Rust's formatting machinery is a little inefficient (there might be a fast path for this in the compiler that makes it just as fast as to_string but to_string is clearer anyway)
    • General replacement of owned heap-based structures like Vec<T> and String with their borrowed counterparts where possible
    • Replace write with write_all, since every case where write was used the returned value was ignored and so if only part of the value could be written you would have ignored that error
    • Make the build script put the generated file into OUT_DIR, which is considered best practice (and in fact if you try to publish a crate, cargo will make sure that you're not generating any files in the source directory during the build)
    • Update to Rust edition 2018 and remove deprecated code

    Great job on this project by the way! None of these issues I've fixed are that bad, they're just less-efficient ways of doing things or minor violations of Rust language style. If you want to get more specific warnings, many of the points above can be found with Clippy. If you run rustup component add clippy and then cargo clippy, you'll get far more warnings than the Rust compiler emits by default.

    opened by Vurich 1
  • Lockless read/write

    Lockless read/write

    I'm not at all familiar with the codebase, but figured it might be worth a look in case you want to consider a similar approach here.

    https://youtu.be/s19G6n0UjsM https://jon.thesquareplanet.com/crates/noria/

    opened by tracker1 1
  • Can not compile on windows

    Can not compile on windows

    Can not compile on windows for x86_64-pc-windows-msvc target with VisualStudio 2019.

    ... almost 50k lines ommited ...
    error: aborting due to 4550 previous errors
    
    For more information about this error, try `rustc --explain E0412`.
    error: Could not compile `kernel32-sys`.
    

    (see full cargo output build.log.msvc.txt)

    kernel32-sys crate is now obsolete and should be replaced with winapi.

    opened by fedorkotov 1
  • Redis Streams: XADD, XRANGE, XREVRANGE

    Redis Streams: XADD, XRANGE, XREVRANGE

    I'm using Redis for some time series logging on a Raspberry Pi, but I just had to compile Redis 5.0 from source for Streams.

    It would be great if rsedis supported Streams with a short guide to embed the same functionality in my Rust program so I can drop Redis as a custom-build dependency :).

    Good luck with your project! Looks cool

    opened by theronic 1
  • Update to the latest nightly and rustfmt the code

    Update to the latest nightly and rustfmt the code

    The code did not compile with rustc 1.13.0-nightly (91f057de3 2016-09-04), so I fixed it.

    I also ran rustfmt on it, in a separate commit, in order to clearly separate semantic changes from style changes.

    The tests, ran with $ tclsh tests/test_helper.tcl, all passed successfully.

    opened by yberreby 1
  • Reuse the address on not-Windows systems

    Reuse the address on not-Windows systems

    Once https://github.com/alexcrichton/net2-rs/pull/6 is merged, this will enable the same behaviour as real Redis.

    I explicitely disabled it for Windows for the known and discussed reasons.

    opened by badboy 1
  • How did you do the implementation?

    How did you do the implementation?

    I am always curious on how people do the "conversion" from one language to another? Did you take the original source code and translated it one file after another or did you take the concepts and try to implement it or another way?

    Sorry for my curious mind. Thanks.

    opened by GeertVL-zz 1
Owner
Sebastian Waisbrot
Sebastian Waisbrot
Sharded, concurrent mini redis that support http interface implemented in rust

Rudis A mini version of redis server that provides http interface implemented in Rust. The in-memorry kv-storage is sharded and concurrent safe. Inspi

Lorenzo Cao 43 May 30, 2023
Redis library for rust

redis-rs Redis-rs is a high level redis library for Rust. It provides convenient access to all Redis functionality through a very flexible but low-lev

Armin Ronacher 2.8k Jan 8, 2023
A rust Key-Value store based on Redis.

Key-Value Store A Key-Value store that uses Redis to store data. Built using an async web framework in Rust with a full Command-Line interface and log

Miguel David Salcedo 0 Jan 14, 2022
Basic Redis Protocol specification in Rust

Basic Redis Protocol specification in Rust

Bruno 1 Jan 20, 2022
Rewrite Redis in Rust for evaluation and learning.

Drill-Redis This library has been created for the purpose of evaluating Rust functionality and performance. As such, it has not been fully tested. The

Akira Kawahara 3 Oct 18, 2022
Redis compatible server framework for Rust

Redis compatible server framework for Rust Features Create a fast custom Redis compatible server in Rust Simple API. Support for pipelining and telnet

Josh Baker 61 Nov 12, 2022
An intentionally-limited Rust implementation of the Redis server with no external dependencies.

lil-redis An intentionally-limited Rust implementation of the Redis server. lil redis is an accessible implementation of a very basic Redis server (wi

Miguel Piedrafita 37 Jan 1, 2023
📺 Netflix in Rust/ React-TS/ NextJS, Actix-Web, Async Apollo-GraphQl, Cassandra/ ScyllaDB, Async SQLx, Kafka, Redis, Tokio, Actix, Elasticsearch, Influxdb Iox, Tensorflow, AWS

Fullstack Movie Streaming Platform ?? Netflix in RUST/ NextJS, Actix-Web, Async Apollo-GraphQl, Cassandra/ ScyllaDB, Async SQLx, Spark, Kafka, Redis,

null 34 Apr 17, 2023
Lightweight async Redis client with connection pooling written in pure Rust and 100% memory safe

redi-rs (or redirs) redi-rs is a Lightweight Redis client with connection pooling written in Rust and 100% memory safe redi-rs is a Redis client writt

Oğuz Türkay 4 May 20, 2023
Simple and flexible queue implementation for Rust with support for multiple backends (Redis, RabbitMQ, SQS, etc.)

Omniqueue Omniqueue is an abstraction layer over queue backends for Rust. It includes support for RabbitMQ, Redis streams, and SQS out of the box. The

Svix 8 May 26, 2023
Learning Rust by implementing parts of redis.

Redis This is a simple CLI Redis inspired project that supports the GET, SET, and INCR commands. Run it Have rust installed (if you don't, visit rustu

Shahzeb K. 3 Mar 28, 2024
RedisLess is a fast, lightweight, embedded and scalable in-memory Key/Value store library compatible with the Redis API.

RedisLess is a fast, lightweight, embedded and scalable in-memory Key/Value store library compatible with the Redis API.

Qovery 145 Nov 23, 2022
RedisJSON - a JSON data type for Redis

RedisJSON RedisJSON is a Redis module that implements ECMA-404 The JSON Data Interchange Standard as a native data type. It allows storing, updating a

null 3.4k Jan 1, 2023
[POC] Redis Module for TiKV

RedisTikvPoc [POC] Redis Module for TiKV This is a POC repository. This Redis Module will add branch new Redis commands to operate TiKV data. After bu

Rain Li 6 Jun 25, 2022
Incomplete Redis client and server implementation using Tokio - for learning purposes only

mini-redis mini-redis is an incomplete, idiomatic implementation of a Redis client and server built with Tokio. The intent of this project is to provi

Tokio 2.3k Jan 4, 2023
A port of `java.util.*SummaryStatistics` as a Redis Module

RedisNumbersStats RedisNumbersStats is a Redis module that implements a Redis version of the Java Util *SummaryStatistics classes, such as DoubleSumma

Brian Sam-Bodden 4 Oct 4, 2022
A simplified version of a Redis server supporting SET/GET commands

This is a starting point for Rust solutions to the "Build Your Own Redis" Challenge. In this challenge, you'll build a toy Redis clone that's capable

Patrick Neilson 2 Nov 15, 2022
Macros for redis-rs to serialize and deserialize structs automatically

redis-macros Simple macros and wrappers to redis-rs to automatically serialize and deserialize structs with serde. Installation To install it, simply

Daniel Grant 4 Feb 18, 2023
A cross-platform redis gui client

Redis-Manager A cross-platform redis gui client started developing with Tauri, React and Typescript in Vite. Get Started Prerequisites Install Node.js

Kurisu 11 Mar 31, 2023