SlideShare a Scribd company logo
PRESENTED BY
Writing Redis Modules in Rust
Gavrie Philipson
Redis Labs, Software Architect
PRESENTED BY
• Blazingly fast
• Memory-efficient
• Safe
What is Rust?
PRESENTED BY
• Friendly compiler
• Useful error messages
• Cargo
What is Rust?
PRESENTED BY
• Redis Modules run in the same memory space as Redis
• A bad memory access can crash the whole redis-server process
• Memory leaks will waste precious Redis memory
• We need safe memory access!
Why use Rust for writing Redis modules?
PRESENTED BY
• Redis is (mostly) single-threaded
• A slow module will slow down Redis
• We need performance!
• Rust’s safety does not mean reduced performance
• We can have nice things
Why use Rust for writing Redis modules?
PRESENTED BY
Why Rust: Writing safe code in C is Hard
1970 1976 1982 1988 1995 2001 2007 2013 2019
C
1972
• Features raw pointers, raw memory access, pointer arithmetic
• Memory management is handled explicitly by the developer
• No standard way to handle errors

PRESENTED BY
Why Rust: C++ looks great on paper, but…
1970 1976 1982 1988 1995 2001 2007 2013 2019
C++
1985
C
1972
• Enormously complex language
• Inscrutable error messages
• Includes all of unsafe C inside

PRESENTED BY
Why Rust: Strong type system, type inference, functional look
and feel
1970 1976 1982 1988 1995 2001 2007 2013 2019
TypeScript
2012
Scala
2004
Swift
2014
Kotlin
2011
Rust
2010
Go
2009
Java
1995
JS
1995
C++
1985
C
1972
PRESENTED BY
Show me the code already!
PRESENTED BY
typedef struct Person {
char *name;
int age;
} Person;
int main() {
Person person = { .name="Joe", .age=25 };
Person *somebody = &person;
printf("%s is %dn", somebody->name, somebody->age);
}
A simple program
PRESENTED BY
struct Person {
name: &'static str,
age: i32,
}
fn main() {
let person = Person { name: "Joe", age: 25 };
let somebody = &person;
println!("{} is {}", somebody.name, somebody.age);
}
Rust: The equivalent code
PRESENTED BY
struct Person {
name: &'static str,
age: i32,
}
fn main() {
let person = Person { name: "Joe", age: 25 };
person.age = 30; // Error: person is immutable
}
Rust: Immutable is the default
PRESENTED BY
struct Person {
name: &'static str,
age: i32,
}
fn main() {
let mut person = Person { name: "Joe", age: 25 };
person.age = 30;
}
Rust: Mutability must be specified explicitly
PRESENTED BY
struct Vec<T> {
buf: ...,
len: usize,
}
let mut languages: Vec<&str> = Vec::new();
languages.push("C");
languages.push("C++");
languages.push(“Rust");
Rust: Using generic containers
PRESENTED BY
• Code that modifies other code at compile time
• Can create new syntax in the language
let languages = vec!["C", "C++", "Rust"];
Rust: Avoiding the boilerplate: Macros!
PRESENTED BY
Rust: Sum types
PRESENTED BY
// Type-safe JSON Value
enum Value {
Null,
Bool(bool),
Number(f64),
String(String),
Array(Vec<Value>),
Object(Map<String, Value>),
}
Rust: Sum types
PRESENTED BY
let full_name = "John Doe";
let age_last_year = 42;
let john = json!({
"name": full_name,
"age": age_last_year + 1,
"phones": [
"+972-50-1234567",
"+972-3-7654321",
]
});
Rust: Sum types + Macros
PRESENTED BY
let val = match john {
Value::Null => "null",
Value::Bool(b) => format!("boolean: {}", b),
Value::Number(n) => format!("number: {}", n),
Value::String(_) => "string",
Value::Array(_) => "array",
Value::Object(_) => "object",
};
Rust: Pattern matching
PRESENTED BY
Enough of this, I want Redis modules in Rust!
PRESENTED BY
Existing Redis modules written in Rust:
• redis-cell by Brandur, 2016
• redismodule by Faineance, 2016
• redis-multi-map by Garrett Squire, 2018
Redis Modules: Creating a Rust API
PRESENTED BY
int hello_command(
RedisModuleCtx *ctx,
RedisModuleString **argv,
int argc
)
Redis Modules: C function defining a Redis command
PRESENTED BY
extern fn hello_command(
ctx: *mut RedisModuleCtx,
argv: *mut *mut RedisModuleString,
argc: c_int,
) -> c_int
Redis Modules: Rust equivalent using C FFI
PRESENTED BY
int hello_command(
RedisModuleCtx *ctx,
RedisModuleString **argv,
int argc
) {
if (argc != 2) return RedisModule_WrongArity(ctx);
return REDISMODULE_OK;
}
Redis Modules: C function defining a Redis command
PRESENTED BY
extern fn hello_command(
ctx: *mut RedisModuleCtx,
argv: *mut *mut RedisModuleString,
argc: c_int,
) -> c_int {
if argc != 2 { return RedisModule_WrongArity(ctx); }
REDISMODULE_OK
}
Redis Modules: Rust equivalent using C FFI
PRESENTED BY
extern fn hello_command(
ctx: *mut RedisModuleCtx,
argv: *mut *mut RedisModuleString,
argc: c_int,
) -> c_int {
if argc != 2 {
unsafe { return RedisModule_WrongArity(ctx); }
}
REDISMODULE_OK
}
Redis Modules: Rust equivalent using C FFI
PRESENTED BY
Nice, but this is just C in a Rust disguise
PRESENTED BY
let f = File::open("foo");
Rust: Error handling
PRESENTED BY
let f: Result<File, Error> = File::open("foo");
Rust: Error handling
PRESENTED BY
let f: Result<File, Error> = File::open("foo");
enum Result<T, E> {
Ok(T),
Err(E),
}
Rust: Error handling: The Result type
PRESENTED BY
let f: Result<File, Error> = File::open("foo");
enum Result<T, E> {
Ok(T),
Err(E),
}
match f {
Ok(file) => { file.bytes(); }
Err(err) => { println!("{}", err); }
}
Rust: Pattern matching on the Result
PRESENTED BY
extern fn hello_command(
ctx: *mut RedisModuleCtx,
argv: *mut *mut RedisModuleString,
argc: c_int,
) -> c_int
Redis Modules: The C equivalent again
PRESENTED BY
fn hello_command(
ctx: &Context,
args: Vec<String>,
) -> Result<RedisValue, RedisError>
Redis Modules: Idiomatic Rust function
PRESENTED BY
fn hello_command(
ctx: &Context,
args: Vec<String>,
) -> Result<RedisValue, RedisError> {
if args.len() != 2 {
return Err(RedisError::WrongArity);
}
Ok(RedisValue::None)
}
Idiomatic Rust binding
PRESENTED BY
• For each command, we need to:
• Implement it as a pure Rust function
• Write an extern C wrapper function that Redis can call
• Convert the arguments and return value
We need to write lots of boilerplate code :-(
PRESENTED BY
• We define a redis_command macro that generates the code for us:
redis_command!(ctx, "hello", hello_command, "");
Macros to the rescue!
PRESENTED BY
• We also define a redis_module macro that:
• Calls the necessary setup functions for a Redis module
• Sets up each Redis command by calling redis_command
Macros to the rescue!
PRESENTED BY
fn hello(ctx: &Context, args: Vec<String>) -> Result<…> {
let key = args.into_iter().skip(1).next_string()?;
let greeting = format!("Hello, {}!", key);
Ok(greeting.into())
}
redis_module! {
name: "hello",
version: 1,
commands: [["hello", hello, ""]],
}
A sample Redis module in Rust
PRESENTED BY
127.0.0.1:6379> MODULE LOAD libhello.so
OK
127.0.0.1:6379> HELLO
(error) ERR wrong number of arguments for 'HELLO' command
127.0.0.1:6379> HELLO world
"Hello, world!"
127.0.0.1:6379>
Running the module
PRESENTED BY
• https://github.com/RedisLabsModules/redismodule-rs/
• Still in early stages
• Contributions are more than welcome!
• Find me at gavrie@redislabs.com or @gavrieph
Check out the code
Thank you!
PRESENTED BY

More Related Content

What's hot

Asynchronous IO in Rust - Enrico Risa - Codemotion Rome 2017
Asynchronous IO in Rust - Enrico Risa - Codemotion Rome 2017Asynchronous IO in Rust - Enrico Risa - Codemotion Rome 2017
Asynchronous IO in Rust - Enrico Risa - Codemotion Rome 2017
Codemotion
 
Asynchronous single page applications without a line of HTML or Javascript, o...
Asynchronous single page applications without a line of HTML or Javascript, o...Asynchronous single page applications without a line of HTML or Javascript, o...
Asynchronous single page applications without a line of HTML or Javascript, o...
Robert Schadek
 
Server side JavaScript: going all the way
Server side JavaScript: going all the wayServer side JavaScript: going all the way
Server side JavaScript: going all the way
Oleg Podsechin
 
Codable routing
Codable routingCodable routing
Codable routing
Pushkar Kulkarni
 
Andrew Druk, Android Developer, Readdie
Andrew Druk, Android Developer, ReaddieAndrew Druk, Android Developer, Readdie
Andrew Druk, Android Developer, Readdie
DataArt
 
不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)
Douglas Chen
 
Briefly Rust - Daniele Esposti - Codemotion Rome 2017
Briefly Rust - Daniele Esposti - Codemotion Rome 2017Briefly Rust - Daniele Esposti - Codemotion Rome 2017
Briefly Rust - Daniele Esposti - Codemotion Rome 2017
Codemotion
 
DaNode - A home made web server in D
DaNode - A home made web server in DDaNode - A home made web server in D
DaNode - A home made web server in D
Andrei Alexandrescu
 
Rcpp11
Rcpp11Rcpp11
Introduction to gdb
Introduction to gdbIntroduction to gdb
Introduction to gdb
Owen Hsu
 
node ffi
node ffinode ffi
node ffi
偉格 高
 
Build microservice with gRPC in golang
Build microservice with gRPC in golangBuild microservice with gRPC in golang
Build microservice with gRPC in golang
Ting-Li Chou
 
Hacking Go Compiler Internals / GoCon 2014 Autumn
Hacking Go Compiler Internals / GoCon 2014 AutumnHacking Go Compiler Internals / GoCon 2014 Autumn
Hacking Go Compiler Internals / GoCon 2014 Autumn
Moriyoshi Koizumi
 
Hiveminder - Everything but the Secret Sauce
Hiveminder - Everything but the Secret SauceHiveminder - Everything but the Secret Sauce
Hiveminder - Everything but the Secret Sauce
Jesse Vincent
 
Untitled presentation(4)
Untitled presentation(4)Untitled presentation(4)
Untitled presentation(4)
chan20kaur
 
ConFess Vienna 2015 - Metaprogramming with Groovy
ConFess Vienna 2015 - Metaprogramming with GroovyConFess Vienna 2015 - Metaprogramming with Groovy
ConFess Vienna 2015 - Metaprogramming with Groovy
Iván López Martín
 
Ctf hello,world!
Ctf hello,world! Ctf hello,world!
Ctf hello,world!
Hacks in Taiwan (HITCON)
 
ECMAScript 6 and the Node Driver
ECMAScript 6 and the Node DriverECMAScript 6 and the Node Driver
ECMAScript 6 and the Node Driver
MongoDB
 
DConf 2016: Keynote by Walter Bright
DConf 2016: Keynote by Walter Bright DConf 2016: Keynote by Walter Bright
DConf 2016: Keynote by Walter Bright
Andrei Alexandrescu
 
Metaprogramming
MetaprogrammingMetaprogramming
Metaprogramming
Mehmet Emin İNAÇ
 

What's hot (20)

Asynchronous IO in Rust - Enrico Risa - Codemotion Rome 2017
Asynchronous IO in Rust - Enrico Risa - Codemotion Rome 2017Asynchronous IO in Rust - Enrico Risa - Codemotion Rome 2017
Asynchronous IO in Rust - Enrico Risa - Codemotion Rome 2017
 
Asynchronous single page applications without a line of HTML or Javascript, o...
Asynchronous single page applications without a line of HTML or Javascript, o...Asynchronous single page applications without a line of HTML or Javascript, o...
Asynchronous single page applications without a line of HTML or Javascript, o...
 
Server side JavaScript: going all the way
Server side JavaScript: going all the wayServer side JavaScript: going all the way
Server side JavaScript: going all the way
 
Codable routing
Codable routingCodable routing
Codable routing
 
Andrew Druk, Android Developer, Readdie
Andrew Druk, Android Developer, ReaddieAndrew Druk, Android Developer, Readdie
Andrew Druk, Android Developer, Readdie
 
不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)
 
Briefly Rust - Daniele Esposti - Codemotion Rome 2017
Briefly Rust - Daniele Esposti - Codemotion Rome 2017Briefly Rust - Daniele Esposti - Codemotion Rome 2017
Briefly Rust - Daniele Esposti - Codemotion Rome 2017
 
DaNode - A home made web server in D
DaNode - A home made web server in DDaNode - A home made web server in D
DaNode - A home made web server in D
 
Rcpp11
Rcpp11Rcpp11
Rcpp11
 
Introduction to gdb
Introduction to gdbIntroduction to gdb
Introduction to gdb
 
node ffi
node ffinode ffi
node ffi
 
Build microservice with gRPC in golang
Build microservice with gRPC in golangBuild microservice with gRPC in golang
Build microservice with gRPC in golang
 
Hacking Go Compiler Internals / GoCon 2014 Autumn
Hacking Go Compiler Internals / GoCon 2014 AutumnHacking Go Compiler Internals / GoCon 2014 Autumn
Hacking Go Compiler Internals / GoCon 2014 Autumn
 
Hiveminder - Everything but the Secret Sauce
Hiveminder - Everything but the Secret SauceHiveminder - Everything but the Secret Sauce
Hiveminder - Everything but the Secret Sauce
 
Untitled presentation(4)
Untitled presentation(4)Untitled presentation(4)
Untitled presentation(4)
 
ConFess Vienna 2015 - Metaprogramming with Groovy
ConFess Vienna 2015 - Metaprogramming with GroovyConFess Vienna 2015 - Metaprogramming with Groovy
ConFess Vienna 2015 - Metaprogramming with Groovy
 
Ctf hello,world!
Ctf hello,world! Ctf hello,world!
Ctf hello,world!
 
ECMAScript 6 and the Node Driver
ECMAScript 6 and the Node DriverECMAScript 6 and the Node Driver
ECMAScript 6 and the Node Driver
 
DConf 2016: Keynote by Walter Bright
DConf 2016: Keynote by Walter Bright DConf 2016: Keynote by Walter Bright
DConf 2016: Keynote by Walter Bright
 
Metaprogramming
MetaprogrammingMetaprogramming
Metaprogramming
 

Similar to Writing Redis Modules In Rust: Gavrie Philipson

Developing a Redis Module - Hackathon Kickoff
 Developing a Redis Module - Hackathon Kickoff Developing a Redis Module - Hackathon Kickoff
Developing a Redis Module - Hackathon Kickoff
Itamar Haber
 
Writing Redis Module with Rust
Writing Redis Module with RustWriting Redis Module with Rust
Writing Redis Module with Rust
Poga Po
 
Android RenderScript
Android RenderScriptAndroid RenderScript
Android RenderScript
Jungsoo Nam
 
Extend Redis with Modules
Extend Redis with ModulesExtend Redis with Modules
Extend Redis with Modules
Itamar Haber
 
1 c introduction
1 c introduction1 c introduction
1 c introduction
suresh rathod
 
Tailoring Redis Modules For Your Users’ Needs
Tailoring Redis Modules For Your Users’ NeedsTailoring Redis Modules For Your Users’ Needs
Tailoring Redis Modules For Your Users’ Needs
Redis Labs
 
Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012
rivierarb
 
IOC + Javascript
IOC + JavascriptIOC + Javascript
IOC + Javascript
Brian Cavalier
 
.NET Foundation, Future of .NET and C#
.NET Foundation, Future of .NET and C#.NET Foundation, Future of .NET and C#
.NET Foundation, Future of .NET and C#
Bertrand Le Roy
 
Next .NET and C#
Next .NET and C#Next .NET and C#
Next .NET and C#
Bertrand Le Roy
 
Modify this code to use multiple threads with the same data1.Modif.pdf
Modify this code to use multiple threads with the same data1.Modif.pdfModify this code to use multiple threads with the same data1.Modif.pdf
Modify this code to use multiple threads with the same data1.Modif.pdf
mallik3000
 
Redis modules 101
Redis modules 101Redis modules 101
Redis modules 101
Dvir Volk
 
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
eugeniadean34240
 
Comredis
ComredisComredis
Comredis
Iuri Fernandes
 
From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...
Jérôme Petazzoni
 
The Joy of ServerSide Swift Development
The Joy  of ServerSide Swift DevelopmentThe Joy  of ServerSide Swift Development
The Joy of ServerSide Swift Development
Giordano Scalzo
 
The Joy of Server Side Swift Development
The Joy  of Server Side Swift DevelopmentThe Joy  of Server Side Swift Development
The Joy of Server Side Swift Development
Giordano Scalzo
 
The Joy Of Server Side Swift Development
The Joy Of Server Side Swift DevelopmentThe Joy Of Server Side Swift Development
The Joy Of Server Side Swift Development
Giordano Scalzo
 
Tamir Dresher - Demystifying the Core of .NET Core
Tamir Dresher  - Demystifying the Core of .NET CoreTamir Dresher  - Demystifying the Core of .NET Core
Tamir Dresher - Demystifying the Core of .NET Core
Tamir Dresher
 
Oops presentation
Oops presentationOops presentation
Oops presentation
sushamaGavarskar1
 

Similar to Writing Redis Modules In Rust: Gavrie Philipson (20)

Developing a Redis Module - Hackathon Kickoff
 Developing a Redis Module - Hackathon Kickoff Developing a Redis Module - Hackathon Kickoff
Developing a Redis Module - Hackathon Kickoff
 
Writing Redis Module with Rust
Writing Redis Module with RustWriting Redis Module with Rust
Writing Redis Module with Rust
 
Android RenderScript
Android RenderScriptAndroid RenderScript
Android RenderScript
 
Extend Redis with Modules
Extend Redis with ModulesExtend Redis with Modules
Extend Redis with Modules
 
1 c introduction
1 c introduction1 c introduction
1 c introduction
 
Tailoring Redis Modules For Your Users’ Needs
Tailoring Redis Modules For Your Users’ NeedsTailoring Redis Modules For Your Users’ Needs
Tailoring Redis Modules For Your Users’ Needs
 
Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012Ruby C extensions at the Ruby drink-up of Sophia, April 2012
Ruby C extensions at the Ruby drink-up of Sophia, April 2012
 
IOC + Javascript
IOC + JavascriptIOC + Javascript
IOC + Javascript
 
.NET Foundation, Future of .NET and C#
.NET Foundation, Future of .NET and C#.NET Foundation, Future of .NET and C#
.NET Foundation, Future of .NET and C#
 
Next .NET and C#
Next .NET and C#Next .NET and C#
Next .NET and C#
 
Modify this code to use multiple threads with the same data1.Modif.pdf
Modify this code to use multiple threads with the same data1.Modif.pdfModify this code to use multiple threads with the same data1.Modif.pdf
Modify this code to use multiple threads with the same data1.Modif.pdf
 
Redis modules 101
Redis modules 101Redis modules 101
Redis modules 101
 
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
 
Comredis
ComredisComredis
Comredis
 
From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...From development environments to production deployments with Docker, Compose,...
From development environments to production deployments with Docker, Compose,...
 
The Joy of ServerSide Swift Development
The Joy  of ServerSide Swift DevelopmentThe Joy  of ServerSide Swift Development
The Joy of ServerSide Swift Development
 
The Joy of Server Side Swift Development
The Joy  of Server Side Swift DevelopmentThe Joy  of Server Side Swift Development
The Joy of Server Side Swift Development
 
The Joy Of Server Side Swift Development
The Joy Of Server Side Swift DevelopmentThe Joy Of Server Side Swift Development
The Joy Of Server Side Swift Development
 
Tamir Dresher - Demystifying the Core of .NET Core
Tamir Dresher  - Demystifying the Core of .NET CoreTamir Dresher  - Demystifying the Core of .NET Core
Tamir Dresher - Demystifying the Core of .NET Core
 
Oops presentation
Oops presentationOops presentation
Oops presentation
 

More from Redis Labs

Redis Day Bangalore 2020 - Session state caching with redis
Redis Day Bangalore 2020 - Session state caching with redisRedis Day Bangalore 2020 - Session state caching with redis
Redis Day Bangalore 2020 - Session state caching with redis
Redis Labs
 
Protecting Your API with Redis by Jane Paek - Redis Day Seattle 2020
Protecting Your API with Redis by Jane Paek - Redis Day Seattle 2020Protecting Your API with Redis by Jane Paek - Redis Day Seattle 2020
Protecting Your API with Redis by Jane Paek - Redis Day Seattle 2020
Redis Labs
 
The Happy Marriage of Redis and Protobuf by Scott Haines of Twilio - Redis Da...
The Happy Marriage of Redis and Protobuf by Scott Haines of Twilio - Redis Da...The Happy Marriage of Redis and Protobuf by Scott Haines of Twilio - Redis Da...
The Happy Marriage of Redis and Protobuf by Scott Haines of Twilio - Redis Da...
Redis Labs
 
SQL, Redis and Kubernetes by Paul Stanton of Windocks - Redis Day Seattle 2020
SQL, Redis and Kubernetes by Paul Stanton of Windocks - Redis Day Seattle 2020SQL, Redis and Kubernetes by Paul Stanton of Windocks - Redis Day Seattle 2020
SQL, Redis and Kubernetes by Paul Stanton of Windocks - Redis Day Seattle 2020
Redis Labs
 
Rust and Redis - Solving Problems for Kubernetes by Ravi Jagannathan of VMwar...
Rust and Redis - Solving Problems for Kubernetes by Ravi Jagannathan of VMwar...Rust and Redis - Solving Problems for Kubernetes by Ravi Jagannathan of VMwar...
Rust and Redis - Solving Problems for Kubernetes by Ravi Jagannathan of VMwar...
Redis Labs
 
Redis for Data Science and Engineering by Dmitry Polyakovsky of Oracle
Redis for Data Science and Engineering by Dmitry Polyakovsky of OracleRedis for Data Science and Engineering by Dmitry Polyakovsky of Oracle
Redis for Data Science and Engineering by Dmitry Polyakovsky of Oracle
Redis Labs
 
Practical Use Cases for ACLs in Redis 6 by Jamie Scott - Redis Day Seattle 2020
Practical Use Cases for ACLs in Redis 6 by Jamie Scott - Redis Day Seattle 2020Practical Use Cases for ACLs in Redis 6 by Jamie Scott - Redis Day Seattle 2020
Practical Use Cases for ACLs in Redis 6 by Jamie Scott - Redis Day Seattle 2020
Redis Labs
 
Moving Beyond Cache by Yiftach Shoolman Redis Labs - Redis Day Seattle 2020
Moving Beyond Cache by Yiftach Shoolman Redis Labs - Redis Day Seattle 2020Moving Beyond Cache by Yiftach Shoolman Redis Labs - Redis Day Seattle 2020
Moving Beyond Cache by Yiftach Shoolman Redis Labs - Redis Day Seattle 2020
Redis Labs
 
Leveraging Redis for System Monitoring by Adam McCormick of SBG - Redis Day S...
Leveraging Redis for System Monitoring by Adam McCormick of SBG - Redis Day S...Leveraging Redis for System Monitoring by Adam McCormick of SBG - Redis Day S...
Leveraging Redis for System Monitoring by Adam McCormick of SBG - Redis Day S...
Redis Labs
 
JSON in Redis - When to use RedisJSON by Jay Won of Coupang - Redis Day Seatt...
JSON in Redis - When to use RedisJSON by Jay Won of Coupang - Redis Day Seatt...JSON in Redis - When to use RedisJSON by Jay Won of Coupang - Redis Day Seatt...
JSON in Redis - When to use RedisJSON by Jay Won of Coupang - Redis Day Seatt...
Redis Labs
 
Highly Available Persistent Session Management Service by Mohamed Elmergawi o...
Highly Available Persistent Session Management Service by Mohamed Elmergawi o...Highly Available Persistent Session Management Service by Mohamed Elmergawi o...
Highly Available Persistent Session Management Service by Mohamed Elmergawi o...
Redis Labs
 
Anatomy of a Redis Command by Madelyn Olson of Amazon Web Services - Redis Da...
Anatomy of a Redis Command by Madelyn Olson of Amazon Web Services - Redis Da...Anatomy of a Redis Command by Madelyn Olson of Amazon Web Services - Redis Da...
Anatomy of a Redis Command by Madelyn Olson of Amazon Web Services - Redis Da...
Redis Labs
 
Building a Multi-dimensional Analytics Engine with RedisGraph by Matthew Goos...
Building a Multi-dimensional Analytics Engine with RedisGraph by Matthew Goos...Building a Multi-dimensional Analytics Engine with RedisGraph by Matthew Goos...
Building a Multi-dimensional Analytics Engine with RedisGraph by Matthew Goos...
Redis Labs
 
RediSearch 1.6 by Pieter Cailliau - Redis Day Bangalore 2020
RediSearch 1.6 by Pieter Cailliau - Redis Day Bangalore 2020RediSearch 1.6 by Pieter Cailliau - Redis Day Bangalore 2020
RediSearch 1.6 by Pieter Cailliau - Redis Day Bangalore 2020
Redis Labs
 
RedisGraph 2.0 by Pieter Cailliau - Redis Day Bangalore 2020
RedisGraph 2.0 by Pieter Cailliau - Redis Day Bangalore 2020RedisGraph 2.0 by Pieter Cailliau - Redis Day Bangalore 2020
RedisGraph 2.0 by Pieter Cailliau - Redis Day Bangalore 2020
Redis Labs
 
RedisTimeSeries 1.2 by Pieter Cailliau - Redis Day Bangalore 2020
RedisTimeSeries 1.2 by Pieter Cailliau - Redis Day Bangalore 2020RedisTimeSeries 1.2 by Pieter Cailliau - Redis Day Bangalore 2020
RedisTimeSeries 1.2 by Pieter Cailliau - Redis Day Bangalore 2020
Redis Labs
 
RedisAI 0.9 by Sherin Thomas of Tensorwerk - Redis Day Bangalore 2020
RedisAI 0.9 by Sherin Thomas of Tensorwerk - Redis Day Bangalore 2020RedisAI 0.9 by Sherin Thomas of Tensorwerk - Redis Day Bangalore 2020
RedisAI 0.9 by Sherin Thomas of Tensorwerk - Redis Day Bangalore 2020
Redis Labs
 
Rate-Limiting 30 Million requests by Vijay Lakshminarayanan and Girish Koundi...
Rate-Limiting 30 Million requests by Vijay Lakshminarayanan and Girish Koundi...Rate-Limiting 30 Million requests by Vijay Lakshminarayanan and Girish Koundi...
Rate-Limiting 30 Million requests by Vijay Lakshminarayanan and Girish Koundi...
Redis Labs
 
Three Pillars of Observability by Rajalakshmi Raji Srinivasan of Site24x7 Zoh...
Three Pillars of Observability by Rajalakshmi Raji Srinivasan of Site24x7 Zoh...Three Pillars of Observability by Rajalakshmi Raji Srinivasan of Site24x7 Zoh...
Three Pillars of Observability by Rajalakshmi Raji Srinivasan of Site24x7 Zoh...
Redis Labs
 
Solving Complex Scaling Problems by Prashant Kumar and Abhishek Jain of Myntr...
Solving Complex Scaling Problems by Prashant Kumar and Abhishek Jain of Myntr...Solving Complex Scaling Problems by Prashant Kumar and Abhishek Jain of Myntr...
Solving Complex Scaling Problems by Prashant Kumar and Abhishek Jain of Myntr...
Redis Labs
 

More from Redis Labs (20)

Redis Day Bangalore 2020 - Session state caching with redis
Redis Day Bangalore 2020 - Session state caching with redisRedis Day Bangalore 2020 - Session state caching with redis
Redis Day Bangalore 2020 - Session state caching with redis
 
Protecting Your API with Redis by Jane Paek - Redis Day Seattle 2020
Protecting Your API with Redis by Jane Paek - Redis Day Seattle 2020Protecting Your API with Redis by Jane Paek - Redis Day Seattle 2020
Protecting Your API with Redis by Jane Paek - Redis Day Seattle 2020
 
The Happy Marriage of Redis and Protobuf by Scott Haines of Twilio - Redis Da...
The Happy Marriage of Redis and Protobuf by Scott Haines of Twilio - Redis Da...The Happy Marriage of Redis and Protobuf by Scott Haines of Twilio - Redis Da...
The Happy Marriage of Redis and Protobuf by Scott Haines of Twilio - Redis Da...
 
SQL, Redis and Kubernetes by Paul Stanton of Windocks - Redis Day Seattle 2020
SQL, Redis and Kubernetes by Paul Stanton of Windocks - Redis Day Seattle 2020SQL, Redis and Kubernetes by Paul Stanton of Windocks - Redis Day Seattle 2020
SQL, Redis and Kubernetes by Paul Stanton of Windocks - Redis Day Seattle 2020
 
Rust and Redis - Solving Problems for Kubernetes by Ravi Jagannathan of VMwar...
Rust and Redis - Solving Problems for Kubernetes by Ravi Jagannathan of VMwar...Rust and Redis - Solving Problems for Kubernetes by Ravi Jagannathan of VMwar...
Rust and Redis - Solving Problems for Kubernetes by Ravi Jagannathan of VMwar...
 
Redis for Data Science and Engineering by Dmitry Polyakovsky of Oracle
Redis for Data Science and Engineering by Dmitry Polyakovsky of OracleRedis for Data Science and Engineering by Dmitry Polyakovsky of Oracle
Redis for Data Science and Engineering by Dmitry Polyakovsky of Oracle
 
Practical Use Cases for ACLs in Redis 6 by Jamie Scott - Redis Day Seattle 2020
Practical Use Cases for ACLs in Redis 6 by Jamie Scott - Redis Day Seattle 2020Practical Use Cases for ACLs in Redis 6 by Jamie Scott - Redis Day Seattle 2020
Practical Use Cases for ACLs in Redis 6 by Jamie Scott - Redis Day Seattle 2020
 
Moving Beyond Cache by Yiftach Shoolman Redis Labs - Redis Day Seattle 2020
Moving Beyond Cache by Yiftach Shoolman Redis Labs - Redis Day Seattle 2020Moving Beyond Cache by Yiftach Shoolman Redis Labs - Redis Day Seattle 2020
Moving Beyond Cache by Yiftach Shoolman Redis Labs - Redis Day Seattle 2020
 
Leveraging Redis for System Monitoring by Adam McCormick of SBG - Redis Day S...
Leveraging Redis for System Monitoring by Adam McCormick of SBG - Redis Day S...Leveraging Redis for System Monitoring by Adam McCormick of SBG - Redis Day S...
Leveraging Redis for System Monitoring by Adam McCormick of SBG - Redis Day S...
 
JSON in Redis - When to use RedisJSON by Jay Won of Coupang - Redis Day Seatt...
JSON in Redis - When to use RedisJSON by Jay Won of Coupang - Redis Day Seatt...JSON in Redis - When to use RedisJSON by Jay Won of Coupang - Redis Day Seatt...
JSON in Redis - When to use RedisJSON by Jay Won of Coupang - Redis Day Seatt...
 
Highly Available Persistent Session Management Service by Mohamed Elmergawi o...
Highly Available Persistent Session Management Service by Mohamed Elmergawi o...Highly Available Persistent Session Management Service by Mohamed Elmergawi o...
Highly Available Persistent Session Management Service by Mohamed Elmergawi o...
 
Anatomy of a Redis Command by Madelyn Olson of Amazon Web Services - Redis Da...
Anatomy of a Redis Command by Madelyn Olson of Amazon Web Services - Redis Da...Anatomy of a Redis Command by Madelyn Olson of Amazon Web Services - Redis Da...
Anatomy of a Redis Command by Madelyn Olson of Amazon Web Services - Redis Da...
 
Building a Multi-dimensional Analytics Engine with RedisGraph by Matthew Goos...
Building a Multi-dimensional Analytics Engine with RedisGraph by Matthew Goos...Building a Multi-dimensional Analytics Engine with RedisGraph by Matthew Goos...
Building a Multi-dimensional Analytics Engine with RedisGraph by Matthew Goos...
 
RediSearch 1.6 by Pieter Cailliau - Redis Day Bangalore 2020
RediSearch 1.6 by Pieter Cailliau - Redis Day Bangalore 2020RediSearch 1.6 by Pieter Cailliau - Redis Day Bangalore 2020
RediSearch 1.6 by Pieter Cailliau - Redis Day Bangalore 2020
 
RedisGraph 2.0 by Pieter Cailliau - Redis Day Bangalore 2020
RedisGraph 2.0 by Pieter Cailliau - Redis Day Bangalore 2020RedisGraph 2.0 by Pieter Cailliau - Redis Day Bangalore 2020
RedisGraph 2.0 by Pieter Cailliau - Redis Day Bangalore 2020
 
RedisTimeSeries 1.2 by Pieter Cailliau - Redis Day Bangalore 2020
RedisTimeSeries 1.2 by Pieter Cailliau - Redis Day Bangalore 2020RedisTimeSeries 1.2 by Pieter Cailliau - Redis Day Bangalore 2020
RedisTimeSeries 1.2 by Pieter Cailliau - Redis Day Bangalore 2020
 
RedisAI 0.9 by Sherin Thomas of Tensorwerk - Redis Day Bangalore 2020
RedisAI 0.9 by Sherin Thomas of Tensorwerk - Redis Day Bangalore 2020RedisAI 0.9 by Sherin Thomas of Tensorwerk - Redis Day Bangalore 2020
RedisAI 0.9 by Sherin Thomas of Tensorwerk - Redis Day Bangalore 2020
 
Rate-Limiting 30 Million requests by Vijay Lakshminarayanan and Girish Koundi...
Rate-Limiting 30 Million requests by Vijay Lakshminarayanan and Girish Koundi...Rate-Limiting 30 Million requests by Vijay Lakshminarayanan and Girish Koundi...
Rate-Limiting 30 Million requests by Vijay Lakshminarayanan and Girish Koundi...
 
Three Pillars of Observability by Rajalakshmi Raji Srinivasan of Site24x7 Zoh...
Three Pillars of Observability by Rajalakshmi Raji Srinivasan of Site24x7 Zoh...Three Pillars of Observability by Rajalakshmi Raji Srinivasan of Site24x7 Zoh...
Three Pillars of Observability by Rajalakshmi Raji Srinivasan of Site24x7 Zoh...
 
Solving Complex Scaling Problems by Prashant Kumar and Abhishek Jain of Myntr...
Solving Complex Scaling Problems by Prashant Kumar and Abhishek Jain of Myntr...Solving Complex Scaling Problems by Prashant Kumar and Abhishek Jain of Myntr...
Solving Complex Scaling Problems by Prashant Kumar and Abhishek Jain of Myntr...
 

Recently uploaded

Webinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data WarehouseWebinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data Warehouse
Federico Razzoli
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
Zilliz
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Alpen-Adria-Universität
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
Wouter Lemaire
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
saastr
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 

Recently uploaded (20)

Webinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data WarehouseWebinar: Designing a schema for a Data Warehouse
Webinar: Designing a schema for a Data Warehouse
 
Generating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and MilvusGenerating privacy-protected synthetic data using Secludy and Milvus
Generating privacy-protected synthetic data using Secludy and Milvus
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing InstancesEnergy Efficient Video Encoding for Cloud and Edge Computing Instances
Energy Efficient Video Encoding for Cloud and Edge Computing Instances
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
 
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
Deep Dive: AI-Powered Marketing to Get More Leads and Customers with HyperGro...
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 

Writing Redis Modules In Rust: Gavrie Philipson

  • 1. PRESENTED BY Writing Redis Modules in Rust Gavrie Philipson Redis Labs, Software Architect
  • 2. PRESENTED BY • Blazingly fast • Memory-efficient • Safe What is Rust?
  • 3. PRESENTED BY • Friendly compiler • Useful error messages • Cargo What is Rust?
  • 4. PRESENTED BY • Redis Modules run in the same memory space as Redis • A bad memory access can crash the whole redis-server process • Memory leaks will waste precious Redis memory • We need safe memory access! Why use Rust for writing Redis modules?
  • 5. PRESENTED BY • Redis is (mostly) single-threaded • A slow module will slow down Redis • We need performance! • Rust’s safety does not mean reduced performance • We can have nice things Why use Rust for writing Redis modules?
  • 6. PRESENTED BY Why Rust: Writing safe code in C is Hard 1970 1976 1982 1988 1995 2001 2007 2013 2019 C 1972 • Features raw pointers, raw memory access, pointer arithmetic • Memory management is handled explicitly by the developer • No standard way to handle errors

  • 7. PRESENTED BY Why Rust: C++ looks great on paper, but… 1970 1976 1982 1988 1995 2001 2007 2013 2019 C++ 1985 C 1972 • Enormously complex language • Inscrutable error messages • Includes all of unsafe C inside

  • 8. PRESENTED BY Why Rust: Strong type system, type inference, functional look and feel 1970 1976 1982 1988 1995 2001 2007 2013 2019 TypeScript 2012 Scala 2004 Swift 2014 Kotlin 2011 Rust 2010 Go 2009 Java 1995 JS 1995 C++ 1985 C 1972
  • 9. PRESENTED BY Show me the code already!
  • 10. PRESENTED BY typedef struct Person { char *name; int age; } Person; int main() { Person person = { .name="Joe", .age=25 }; Person *somebody = &person; printf("%s is %dn", somebody->name, somebody->age); } A simple program
  • 11. PRESENTED BY struct Person { name: &'static str, age: i32, } fn main() { let person = Person { name: "Joe", age: 25 }; let somebody = &person; println!("{} is {}", somebody.name, somebody.age); } Rust: The equivalent code
  • 12. PRESENTED BY struct Person { name: &'static str, age: i32, } fn main() { let person = Person { name: "Joe", age: 25 }; person.age = 30; // Error: person is immutable } Rust: Immutable is the default
  • 13. PRESENTED BY struct Person { name: &'static str, age: i32, } fn main() { let mut person = Person { name: "Joe", age: 25 }; person.age = 30; } Rust: Mutability must be specified explicitly
  • 14. PRESENTED BY struct Vec<T> { buf: ..., len: usize, } let mut languages: Vec<&str> = Vec::new(); languages.push("C"); languages.push("C++"); languages.push(“Rust"); Rust: Using generic containers
  • 15. PRESENTED BY • Code that modifies other code at compile time • Can create new syntax in the language let languages = vec!["C", "C++", "Rust"]; Rust: Avoiding the boilerplate: Macros!
  • 17. PRESENTED BY // Type-safe JSON Value enum Value { Null, Bool(bool), Number(f64), String(String), Array(Vec<Value>), Object(Map<String, Value>), } Rust: Sum types
  • 18. PRESENTED BY let full_name = "John Doe"; let age_last_year = 42; let john = json!({ "name": full_name, "age": age_last_year + 1, "phones": [ "+972-50-1234567", "+972-3-7654321", ] }); Rust: Sum types + Macros
  • 19. PRESENTED BY let val = match john { Value::Null => "null", Value::Bool(b) => format!("boolean: {}", b), Value::Number(n) => format!("number: {}", n), Value::String(_) => "string", Value::Array(_) => "array", Value::Object(_) => "object", }; Rust: Pattern matching
  • 20. PRESENTED BY Enough of this, I want Redis modules in Rust!
  • 21. PRESENTED BY Existing Redis modules written in Rust: • redis-cell by Brandur, 2016 • redismodule by Faineance, 2016 • redis-multi-map by Garrett Squire, 2018 Redis Modules: Creating a Rust API
  • 22. PRESENTED BY int hello_command( RedisModuleCtx *ctx, RedisModuleString **argv, int argc ) Redis Modules: C function defining a Redis command
  • 23. PRESENTED BY extern fn hello_command( ctx: *mut RedisModuleCtx, argv: *mut *mut RedisModuleString, argc: c_int, ) -> c_int Redis Modules: Rust equivalent using C FFI
  • 24. PRESENTED BY int hello_command( RedisModuleCtx *ctx, RedisModuleString **argv, int argc ) { if (argc != 2) return RedisModule_WrongArity(ctx); return REDISMODULE_OK; } Redis Modules: C function defining a Redis command
  • 25. PRESENTED BY extern fn hello_command( ctx: *mut RedisModuleCtx, argv: *mut *mut RedisModuleString, argc: c_int, ) -> c_int { if argc != 2 { return RedisModule_WrongArity(ctx); } REDISMODULE_OK } Redis Modules: Rust equivalent using C FFI
  • 26. PRESENTED BY extern fn hello_command( ctx: *mut RedisModuleCtx, argv: *mut *mut RedisModuleString, argc: c_int, ) -> c_int { if argc != 2 { unsafe { return RedisModule_WrongArity(ctx); } } REDISMODULE_OK } Redis Modules: Rust equivalent using C FFI
  • 27. PRESENTED BY Nice, but this is just C in a Rust disguise
  • 28. PRESENTED BY let f = File::open("foo"); Rust: Error handling
  • 29. PRESENTED BY let f: Result<File, Error> = File::open("foo"); Rust: Error handling
  • 30. PRESENTED BY let f: Result<File, Error> = File::open("foo"); enum Result<T, E> { Ok(T), Err(E), } Rust: Error handling: The Result type
  • 31. PRESENTED BY let f: Result<File, Error> = File::open("foo"); enum Result<T, E> { Ok(T), Err(E), } match f { Ok(file) => { file.bytes(); } Err(err) => { println!("{}", err); } } Rust: Pattern matching on the Result
  • 32. PRESENTED BY extern fn hello_command( ctx: *mut RedisModuleCtx, argv: *mut *mut RedisModuleString, argc: c_int, ) -> c_int Redis Modules: The C equivalent again
  • 33. PRESENTED BY fn hello_command( ctx: &Context, args: Vec<String>, ) -> Result<RedisValue, RedisError> Redis Modules: Idiomatic Rust function
  • 34. PRESENTED BY fn hello_command( ctx: &Context, args: Vec<String>, ) -> Result<RedisValue, RedisError> { if args.len() != 2 { return Err(RedisError::WrongArity); } Ok(RedisValue::None) } Idiomatic Rust binding
  • 35. PRESENTED BY • For each command, we need to: • Implement it as a pure Rust function • Write an extern C wrapper function that Redis can call • Convert the arguments and return value We need to write lots of boilerplate code :-(
  • 36. PRESENTED BY • We define a redis_command macro that generates the code for us: redis_command!(ctx, "hello", hello_command, ""); Macros to the rescue!
  • 37. PRESENTED BY • We also define a redis_module macro that: • Calls the necessary setup functions for a Redis module • Sets up each Redis command by calling redis_command Macros to the rescue!
  • 38. PRESENTED BY fn hello(ctx: &Context, args: Vec<String>) -> Result<…> { let key = args.into_iter().skip(1).next_string()?; let greeting = format!("Hello, {}!", key); Ok(greeting.into()) } redis_module! { name: "hello", version: 1, commands: [["hello", hello, ""]], } A sample Redis module in Rust
  • 39. PRESENTED BY 127.0.0.1:6379> MODULE LOAD libhello.so OK 127.0.0.1:6379> HELLO (error) ERR wrong number of arguments for 'HELLO' command 127.0.0.1:6379> HELLO world "Hello, world!" 127.0.0.1:6379> Running the module
  • 40. PRESENTED BY • https://github.com/RedisLabsModules/redismodule-rs/ • Still in early stages • Contributions are more than welcome! • Find me at gavrie@redislabs.com or @gavrieph Check out the code