Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Redis-cell, an API rate limiter as a Redis module, written in Rust (github.com/brandur)
15 points by brandur on Nov 17, 2016 | hide | past | favorite | 1 comment



Author here: this was a pretty fun side project to experiment with Redis' (relatively) new module system [1], and to help me learn Rust. It uses Rust's FFI module [2] to call into a C binary, and thanks to Rust's minimal runtime and lack of a GC, this turns out to work out very well. Its benchmarks are quite good [3].

Redis provides a fairly novel API for plugging into it in that instead of using a shared object (.so), it's only exposed as a C header file. To compensate for this in a non-C language, I have a build step that compiles a library for Rust to link against [4]. It was a pleasant surprise to find that this functionality is built right into Rust's compiler.

[1] https://github.com/antirez/redis/blob/unstable/src/modules/I...

[2] https://doc.rust-lang.org/book/ffi.html

[3] https://gist.github.com/brandur/90698498bd543598d00df46e32be...

[4] https://github.com/brandur/redis-cell/blob/master/build.rs




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: