SlideShare una empresa de Scribd logo
1 de 42
Descargar para leer sin conexión
Redis Modules TL;DR
Dvir Volk,
Senior Architect, Redis Labs
So… Modules, huh?
• I’ve been waiting 6 years
• Will change Redis forever IMO
• The key is the API concept
What Modules Actually Are
• Dynamically loaded libraries into redis
• Extend redis with new commands
• Written in C (C++ if you really insist)
• Using a C API designed to isolate redis internals
The Race For JS Modules is ON!
What Modules Can’t Do (YET)
• Register new data structures *
• Override existing commands *
• Block
• Not the entire API of redis is accessible directly
• All Coming Soon
* Not completely true!
Modules in Action
127.0.0.1:9875> MODULE LOAD example.so
OK
127.0.0.1:9875> HSET foo bar baz
(integer) 1
127.0.0.1:9875> HGETSET foo bar w00t!
"baz"
127.0.0.1:9875> HGETSET foo bar wat?
"w00t!"
The Main API Layers
High Level API
● Generic RedisCall
● Basically Lua on steroids
Operational API
● Compose responses, examine call replies
● Memory Management
Low Level API
● Selected parts of redis commands (L*, Z*)
● String DMA
Main Building Blocks
RedisModuleString*
Memory managed strings
for the module
Opaque to the developer
Args and replies
RedisModuleCallReply*
Returned from most calls
Like the protocol can be:
● Strings
● Arrays
● Integers
● Errors
● Null
RedisModuleKey*
References to keys we
are working with, mainly
for the lower level API
Acquired with Open
Released automatically
or with Close
RedisModuleCtx *
● Redis’ execution context for a command
● Opaque to the module developer
● Passed to most functions
● Behind the scenes manages resources
○ Allocated Objects
○ Opened Keys
○ Automatic free at exit
High Level
API
RedisModuleCallReply *rep =
RedisModule_Call(ctx,
"HGET",
"cl",
"foo",
1337);
High Level API
● More or less like LUA’s API
● Generic RedisModule_Call
● Examine replies with RedisModule_CallReplyType
● Reply to the client with RedisModule_ReplyWith*
● Slower than lower level API, but flexible
Low Level API
● MUCH faster
Low Level API
● MUCH faster
● Hash Get/Set
Low Level API
● MUCH faster
● Hash Get/Set
● ZSET operations
Low Level API
● MUCH faster
● Hash Get/Set
● ZSET operations
● ZSET Iterators
Low Level API
● MUCH faster
● Hash Get/Set
● ZSET operations
● ZSET Iterators
● String DMA / truncate
Low Level API
● MUCH faster
● Hash Get/Set
● ZSET operations
● ZSET Iterators
● String DMA / truncate
● List push/pop
Low Level API
● MUCH faster
● Hash Get/Set
● ZSET operations
● ZSET Iterators
● String DMA / truncate
● List push/pop
● Expire
Low Level API
● MUCH faster
● Hash Get/Set
● ZSET operations
● ZSET Iterators
● String DMA / truncate
● List push/pop
● Expire
● More to come!
String DMA
● Use Redis strings as raw memory
● Zero Copy Overhead
● Resize strings with RedisModule_Truncate
● BYODS - Bring Your Own Data Structure
• Basic Module Template
• Complete Documentation
• Automating Boring Stuff
• Argument Parsing
• String Manipulation
• Response Validation
• Testing
https://github.com/RedisLabs/RedisModulesSDK
Shameless Plug: RedisModulesSDK
Let’s Make a Module!
HGETSET <key> <element> <newval>
Step 1: Command Handler
#include “redismodule.h”
/* HGETSET <key> <element> <value> */
int HGetSetCmd(RedisModuleCtx *ctx,
RedisModuleString **argv, int argc) {
return REDISMODULE_OK;
}
Step 2: validate args
/* HGETSET <key> <element> <value> */
int HGetSetCmd(RedisModuleCtx *ctx, RedisModuleString
**argv, int argc) {
if (argc != 4) {
return RedisModule_WrongArity(ctx);
}
return REDISMODULE_OK;
}
Step 3: Auto Memory
/* HGETSET <key> <element> <value> */
int HGetSetCmd(RedisModuleCtx *ctx, RedisModuleString
**argv, int argc) {
if (argc != 4) {
return RedisModule_WrongArity(ctx);
}
RedisModule_AutoMemory(ctx);
return REDISMODULE_OK;
}
Step 4: Making Calls!
/* HGETSET <key> <element> <value> */
int HGetSetCmd(RedisModuleCtx *ctx, RedisModuleString
**argv, int argc) {
…
RedisModuleCallReply *rep = RedisModule_Call(ctx,
"HGET", "ss", argv[1], argv[2]);
RMUTIL_ASSERT_NOERROR(rep)
…
}
Step 4: MOAR CALLZ PLZ
/* HGETSET <key> <element> <value> */
int HGetSetCmd(RedisModuleCtx *ctx, RedisModuleString
**argv, int argc) {
…
RedisModuleCallReply *srep = RedisModule_Call(ctx,
"HSET", "sss", argv[1], argv[2], argv[3]);
REDIS_ASSERT_NOERROR(srep)
return REDISMODULE_OK;
}
Step 5: Returning a reply
/* HGETSET <key> <element> <value> */
int HGetSetCmd(RedisModuleCtx *ctx, RedisModuleString
**argv, int argc) {
…
RedisModule_ReplyWithCallReply(ctx, rep);
return REDISMODULE_OK;
}
Step 6: Initializing
int RedisModule_OnLoad(RedisModuleCtx *ctx) {
if (RedisModule_Init(ctx,"EXAMPLE",1,REDISMODULE_APIVER_1)
== REDISMODULE_ERR) return REDISMODULE_ERR;
if (RedisModule_CreateCmd(ctx,"HGETSET",
HGetSetCommand, “write”, 1, 1, 1) == REDISMODULE_ERR)
return REDISMODULE_ERR;
return REDISMODULE_OK;
}
Step 6: Initializing
int RedisModule_OnLoad(RedisModuleCtx *ctx) {
if (RedisModule_Init(ctx,"EXAMPLE",1,REDISMODULE_APIVER_1)
== REDISMODULE_ERR) return REDISMODULE_ERR;
if (RedisModule_CreateCmd(ctx,"HGETSET",
HGetSetCommand, “write”, 1, 1, 1) == REDISMODULE_ERR)
return REDISMODULE_ERR;
return REDISMODULE_OK;
}
• No special Linking required
• Just #include “redismodule.h”
Building and Makefile
CFLAGS = -Wall -fPIC
LDFLAGS = -shared -Bsymbolic -lc
module.so: module.o
$(LD) -o $@ module.o $(LDFLAGS)
IT WORKS!
127.0.0.1:9875> MODULE LOAD example.so
OK
127.0.0.1:9875> HSET foo bar baz
(integer) 1
127.0.0.1:9875> HGETSET foo bar w00t!
"baz"
127.0.0.1:9875> HGETSET foo bar wat?
"w00t!"
The Low Level API
Low Level API: Example
/* ZSUMRANGE <key> <startscore> <endscore> */
int ZsumRange_RedisCommand(RedisModuleCtx *ctx,
RedisModuleString **argv, int argc) {
return REDISMODULE_OK;
}
Low Level API: Read Arguments
int ZsumRange_RedisCommand(...) {
double min, max;
double sum = 0;
if (MUtil_ParseArgs(argv, argc, 2, "dd", &min, &max)
!= REDISMODULE_OK) {
RedisModule_WrongArity(ctx);
}
...
}
Low Level API: Open The Key
int ZsumRange_RedisCommand(...) {
...
RedisModuleKey *k =
RedisModule_OpenKey(ctx, argv[1], REDISMODULE_READ);
if (RedisModule_KeyType(k) != REDISMODULE_KEYTYPE_ZSET){
return RedisModule_ReplyWithError(...);
}
}
Low Level API: Iterate ZSET
int ZsumRange_RedisCommand(...) {
...
// Open The iterator
RedisModule_ZsetFirstInScoreRange(k, min, max, 0, 0);
while(!RedisModule_ZsetRangeEndReached(k)) {
...
RedisModule_ZsetRangeNext(k);
}
RedisModule_ZsetRangeStop(k);
Low Level API: Read Iterator Values
while(!RedisModule_ZsetRangeEndReached(k)) {
double score;
RedisModuleString *ele =
RedisModule_ZsetRangeCurrentElement(k, &score);
RedisModule_FreeString(ctx, ele);
sum += score;
RedisModule_ZsetRangeNext(k);
}
Low Level API: Return the value
/* ZSUMRANGE key startscore endscore */
int ZsumRange_RedisCommand(RedisModuleCtx *ctx,
RedisModuleString **argv, int argc) {
...
RedisModule_CloseKey(key);
RedisModule_ReplyWithDouble(ctx, sum);
return REDISMODULE_OK;
}
A Little Benchmark
● Sum the scores of 1,000,000 ZSET Elements
● Python client, Lua script, High/Low Level Modules
● Low Level API uses iterators
● The rest use ZRANGEBYSCORE
Benchmark: Results (seconds)
KTHXBAI!

Más contenido relacionado

La actualidad más candente

An Introduction to REDIS NoSQL database
An Introduction to REDIS NoSQL databaseAn Introduction to REDIS NoSQL database
An Introduction to REDIS NoSQL databaseAli MasudianPour
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to RedisKnoldus Inc.
 
Postgres & Redis Sitting in a Tree- Rimas Silkaitis, Heroku
Postgres & Redis Sitting in a Tree- Rimas Silkaitis, HerokuPostgres & Redis Sitting in a Tree- Rimas Silkaitis, Heroku
Postgres & Redis Sitting in a Tree- Rimas Silkaitis, HerokuRedis Labs
 
Scaling php applications with redis
Scaling php applications with redisScaling php applications with redis
Scaling php applications with redisjimbojsb
 
Boosting Machine Learning with Redis Modules and Spark
Boosting Machine Learning with Redis Modules and SparkBoosting Machine Learning with Redis Modules and Spark
Boosting Machine Learning with Redis Modules and SparkDvir Volk
 
Background Tasks in Node - Evan Tahler, TaskRabbit
Background Tasks in Node - Evan Tahler, TaskRabbitBackground Tasks in Node - Evan Tahler, TaskRabbit
Background Tasks in Node - Evan Tahler, TaskRabbitRedis Labs
 
Everything you always wanted to know about Redis but were afraid to ask
Everything you always wanted to know about Redis but were afraid to askEverything you always wanted to know about Redis but were afraid to ask
Everything you always wanted to know about Redis but were afraid to askCarlos Abalde
 
A simple introduction to redis
A simple introduction to redisA simple introduction to redis
A simple introduction to redisZhichao Liang
 
Centralized + Unified Logging
Centralized + Unified LoggingCentralized + Unified Logging
Centralized + Unified LoggingGabor Kozma
 
Redis in Practice: Scenarios, Performance and Practice with PHP
Redis in Practice: Scenarios, Performance and Practice with PHPRedis in Practice: Scenarios, Performance and Practice with PHP
Redis in Practice: Scenarios, Performance and Practice with PHPChen Huang
 
Ceph BlueStore - новый тип хранилища в Ceph / Максим Воронцов, (Redsys)
Ceph BlueStore - новый тип хранилища в Ceph / Максим Воронцов, (Redsys)Ceph BlueStore - новый тип хранилища в Ceph / Максим Воронцов, (Redsys)
Ceph BlueStore - новый тип хранилища в Ceph / Максим Воронцов, (Redsys)Ontico
 
Redis Indices (#RedisTLV)
Redis Indices (#RedisTLV)Redis Indices (#RedisTLV)
Redis Indices (#RedisTLV)Itamar Haber
 
PostgreSQL and Redis - talk at pgcon 2013
PostgreSQL and Redis - talk at pgcon 2013PostgreSQL and Redis - talk at pgcon 2013
PostgreSQL and Redis - talk at pgcon 2013Andrew Dunstan
 
Introduction to redis
Introduction to redisIntroduction to redis
Introduction to redisTanu Siwag
 
Redis — The AK-47 of Post-relational Databases
Redis — The AK-47 of Post-relational DatabasesRedis — The AK-47 of Post-relational Databases
Redis — The AK-47 of Post-relational DatabasesKarel Minarik
 
What's new in Redis v3.2
What's new in Redis v3.2What's new in Redis v3.2
What's new in Redis v3.2Itamar Haber
 
Redis/Lessons learned
Redis/Lessons learnedRedis/Lessons learned
Redis/Lessons learnedTit Petric
 

La actualidad más candente (20)

An Introduction to REDIS NoSQL database
An Introduction to REDIS NoSQL databaseAn Introduction to REDIS NoSQL database
An Introduction to REDIS NoSQL database
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Redis introduction
Redis introductionRedis introduction
Redis introduction
 
Postgres & Redis Sitting in a Tree- Rimas Silkaitis, Heroku
Postgres & Redis Sitting in a Tree- Rimas Silkaitis, HerokuPostgres & Redis Sitting in a Tree- Rimas Silkaitis, Heroku
Postgres & Redis Sitting in a Tree- Rimas Silkaitis, Heroku
 
Scaling php applications with redis
Scaling php applications with redisScaling php applications with redis
Scaling php applications with redis
 
Boosting Machine Learning with Redis Modules and Spark
Boosting Machine Learning with Redis Modules and SparkBoosting Machine Learning with Redis Modules and Spark
Boosting Machine Learning with Redis Modules and Spark
 
Background Tasks in Node - Evan Tahler, TaskRabbit
Background Tasks in Node - Evan Tahler, TaskRabbitBackground Tasks in Node - Evan Tahler, TaskRabbit
Background Tasks in Node - Evan Tahler, TaskRabbit
 
Everything you always wanted to know about Redis but were afraid to ask
Everything you always wanted to know about Redis but were afraid to askEverything you always wanted to know about Redis but were afraid to ask
Everything you always wanted to know about Redis but were afraid to ask
 
A simple introduction to redis
A simple introduction to redisA simple introduction to redis
A simple introduction to redis
 
Redis 101
Redis 101Redis 101
Redis 101
 
Centralized + Unified Logging
Centralized + Unified LoggingCentralized + Unified Logging
Centralized + Unified Logging
 
Redis in Practice: Scenarios, Performance and Practice with PHP
Redis in Practice: Scenarios, Performance and Practice with PHPRedis in Practice: Scenarios, Performance and Practice with PHP
Redis in Practice: Scenarios, Performance and Practice with PHP
 
Ceph BlueStore - новый тип хранилища в Ceph / Максим Воронцов, (Redsys)
Ceph BlueStore - новый тип хранилища в Ceph / Максим Воронцов, (Redsys)Ceph BlueStore - новый тип хранилища в Ceph / Максим Воронцов, (Redsys)
Ceph BlueStore - новый тип хранилища в Ceph / Максим Воронцов, (Redsys)
 
Redis Indices (#RedisTLV)
Redis Indices (#RedisTLV)Redis Indices (#RedisTLV)
Redis Indices (#RedisTLV)
 
PostgreSQL and Redis - talk at pgcon 2013
PostgreSQL and Redis - talk at pgcon 2013PostgreSQL and Redis - talk at pgcon 2013
PostgreSQL and Redis - talk at pgcon 2013
 
Introduction to redis
Introduction to redisIntroduction to redis
Introduction to redis
 
Redis — The AK-47 of Post-relational Databases
Redis — The AK-47 of Post-relational DatabasesRedis — The AK-47 of Post-relational Databases
Redis — The AK-47 of Post-relational Databases
 
What's new in Redis v3.2
What's new in Redis v3.2What's new in Redis v3.2
What's new in Redis v3.2
 
Redis and it's data types
Redis and it's data typesRedis and it's data types
Redis and it's data types
 
Redis/Lessons learned
Redis/Lessons learnedRedis/Lessons learned
Redis/Lessons learned
 

Destacado

Redis High availability and fault tolerance in a multitenant environment
Redis High availability and fault tolerance in a multitenant environmentRedis High availability and fault tolerance in a multitenant environment
Redis High availability and fault tolerance in a multitenant environmentIccha Sethi
 
Redis data modeling examples
Redis data modeling examplesRedis data modeling examples
Redis data modeling examplesTerry Cho
 
Redis Use Patterns (DevconTLV June 2014)
Redis Use Patterns (DevconTLV June 2014)Redis Use Patterns (DevconTLV June 2014)
Redis Use Patterns (DevconTLV June 2014)Itamar Haber
 
Kicking ass with redis
Kicking ass with redisKicking ass with redis
Kicking ass with redisDvir Volk
 
HIgh Performance Redis- Tague Griffith, GoPro
HIgh Performance Redis- Tague Griffith, GoProHIgh Performance Redis- Tague Griffith, GoPro
HIgh Performance Redis- Tague Griffith, GoProRedis Labs
 
Redis & MongoDB: Stop Big Data Indigestion Before It Starts
Redis & MongoDB: Stop Big Data Indigestion Before It StartsRedis & MongoDB: Stop Big Data Indigestion Before It Starts
Redis & MongoDB: Stop Big Data Indigestion Before It StartsItamar Haber
 
Why Your MongoDB Needs Redis
Why Your MongoDB Needs RedisWhy Your MongoDB Needs Redis
Why Your MongoDB Needs RedisItamar Haber
 
Couchdb and me
Couchdb and meCouchdb and me
Couchdb and meiammutex
 
Mysql HandleSocket技术在SNS Feed存储中的应用
Mysql HandleSocket技术在SNS Feed存储中的应用Mysql HandleSocket技术在SNS Feed存储中的应用
Mysql HandleSocket技术在SNS Feed存储中的应用iammutex
 
Ocean base海量结构化数据存储系统 hadoop in china
Ocean base海量结构化数据存储系统 hadoop in chinaOcean base海量结构化数据存储系统 hadoop in china
Ocean base海量结构化数据存储系统 hadoop in chinaknuthocean
 
Consistency Models in New Generation Databases
Consistency Models in New Generation DatabasesConsistency Models in New Generation Databases
Consistency Models in New Generation Databasesiammutex
 
8 minute MongoDB tutorial slide
8 minute MongoDB tutorial slide8 minute MongoDB tutorial slide
8 minute MongoDB tutorial slideiammutex
 
Consistency in Distributed Systems
Consistency in Distributed SystemsConsistency in Distributed Systems
Consistency in Distributed SystemsShane Johnson
 
SDEC2011 NoSQL Data modelling
SDEC2011 NoSQL Data modellingSDEC2011 NoSQL Data modelling
SDEC2011 NoSQL Data modellingKorea Sdec
 
Big Challenges in Data Modeling: NoSQL and Data Modeling
Big Challenges in Data Modeling: NoSQL and Data ModelingBig Challenges in Data Modeling: NoSQL and Data Modeling
Big Challenges in Data Modeling: NoSQL and Data ModelingDATAVERSITY
 
Build a Geospatial App with Redis 3.2- Andrew Bass, Sean Yesmunt, Sergio Prad...
Build a Geospatial App with Redis 3.2- Andrew Bass, Sean Yesmunt, Sergio Prad...Build a Geospatial App with Redis 3.2- Andrew Bass, Sean Yesmunt, Sergio Prad...
Build a Geospatial App with Redis 3.2- Andrew Bass, Sean Yesmunt, Sergio Prad...Redis Labs
 
Getting Started with Redis
Getting Started with RedisGetting Started with Redis
Getting Started with RedisFaisal Akber
 

Destacado (20)

Redis High availability and fault tolerance in a multitenant environment
Redis High availability and fault tolerance in a multitenant environmentRedis High availability and fault tolerance in a multitenant environment
Redis High availability and fault tolerance in a multitenant environment
 
Redis data modeling examples
Redis data modeling examplesRedis data modeling examples
Redis data modeling examples
 
Redis Use Patterns (DevconTLV June 2014)
Redis Use Patterns (DevconTLV June 2014)Redis Use Patterns (DevconTLV June 2014)
Redis Use Patterns (DevconTLV June 2014)
 
Kicking ass with redis
Kicking ass with redisKicking ass with redis
Kicking ass with redis
 
HIgh Performance Redis- Tague Griffith, GoPro
HIgh Performance Redis- Tague Griffith, GoProHIgh Performance Redis- Tague Griffith, GoPro
HIgh Performance Redis- Tague Griffith, GoPro
 
Redis & MongoDB: Stop Big Data Indigestion Before It Starts
Redis & MongoDB: Stop Big Data Indigestion Before It StartsRedis & MongoDB: Stop Big Data Indigestion Before It Starts
Redis & MongoDB: Stop Big Data Indigestion Before It Starts
 
Why Your MongoDB Needs Redis
Why Your MongoDB Needs RedisWhy Your MongoDB Needs Redis
Why Your MongoDB Needs Redis
 
Ha of load balancer
Ha of load balancerHa of load balancer
Ha of load balancer
 
Couchdb and me
Couchdb and meCouchdb and me
Couchdb and me
 
Mysql HandleSocket技术在SNS Feed存储中的应用
Mysql HandleSocket技术在SNS Feed存储中的应用Mysql HandleSocket技术在SNS Feed存储中的应用
Mysql HandleSocket技术在SNS Feed存储中的应用
 
Ooredis
OoredisOoredis
Ooredis
 
Ocean base海量结构化数据存储系统 hadoop in china
Ocean base海量结构化数据存储系统 hadoop in chinaOcean base海量结构化数据存储系统 hadoop in china
Ocean base海量结构化数据存储系统 hadoop in china
 
Consistency Models in New Generation Databases
Consistency Models in New Generation DatabasesConsistency Models in New Generation Databases
Consistency Models in New Generation Databases
 
8 minute MongoDB tutorial slide
8 minute MongoDB tutorial slide8 minute MongoDB tutorial slide
8 minute MongoDB tutorial slide
 
Consistency in Distributed Systems
Consistency in Distributed SystemsConsistency in Distributed Systems
Consistency in Distributed Systems
 
SDEC2011 NoSQL Data modelling
SDEC2011 NoSQL Data modellingSDEC2011 NoSQL Data modelling
SDEC2011 NoSQL Data modelling
 
Big Challenges in Data Modeling: NoSQL and Data Modeling
Big Challenges in Data Modeling: NoSQL and Data ModelingBig Challenges in Data Modeling: NoSQL and Data Modeling
Big Challenges in Data Modeling: NoSQL and Data Modeling
 
skip list
skip listskip list
skip list
 
Build a Geospatial App with Redis 3.2- Andrew Bass, Sean Yesmunt, Sergio Prad...
Build a Geospatial App with Redis 3.2- Andrew Bass, Sean Yesmunt, Sergio Prad...Build a Geospatial App with Redis 3.2- Andrew Bass, Sean Yesmunt, Sergio Prad...
Build a Geospatial App with Redis 3.2- Andrew Bass, Sean Yesmunt, Sergio Prad...
 
Getting Started with Redis
Getting Started with RedisGetting Started with Redis
Getting Started with Redis
 

Similar a Redis modules 101

Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to RedisRizky Abdilah
 
Redis Modules API - an introduction
Redis Modules API - an introductionRedis Modules API - an introduction
Redis Modules API - an introductionItamar Haber
 
Developing a Redis Module - Hackathon Kickoff
 Developing a Redis Module - Hackathon Kickoff Developing a Redis Module - Hackathon Kickoff
Developing a Redis Module - Hackathon KickoffItamar Haber
 
[db tech showcase Tokyo 2014] B15: Scalability with MariaDB and MaxScale by ...
[db tech showcase Tokyo 2014] B15: Scalability with MariaDB and MaxScale  by ...[db tech showcase Tokyo 2014] B15: Scalability with MariaDB and MaxScale  by ...
[db tech showcase Tokyo 2014] B15: Scalability with MariaDB and MaxScale by ...Insight Technology, Inc.
 
MySQL 5.7 in a Nutshell
MySQL 5.7 in a NutshellMySQL 5.7 in a Nutshell
MySQL 5.7 in a NutshellEmily Ikuta
 
LA Ember.js Meetup, Jan 2017
LA Ember.js Meetup, Jan 2017LA Ember.js Meetup, Jan 2017
LA Ember.js Meetup, Jan 2017Matthew Beale
 
Postgres Vienna DB Meetup 2014
Postgres Vienna DB Meetup 2014Postgres Vienna DB Meetup 2014
Postgres Vienna DB Meetup 2014Michael Renner
 
Orchestrating Redis & K8s Operators
Orchestrating Redis & K8s OperatorsOrchestrating Redis & K8s Operators
Orchestrating Redis & K8s OperatorsDoiT International
 
Writing Redis Modules In Rust: Gavrie Philipson
Writing Redis Modules In Rust: Gavrie PhilipsonWriting Redis Modules In Rust: Gavrie Philipson
Writing Redis Modules In Rust: Gavrie PhilipsonRedis Labs
 
Building and Scaling Node.js Applications
Building and Scaling Node.js ApplicationsBuilding and Scaling Node.js Applications
Building and Scaling Node.js ApplicationsOhad Kravchick
 
An Introduction to Redis for .NET Developers.pdf
An Introduction to Redis for .NET Developers.pdfAn Introduction to Redis for .NET Developers.pdf
An Introduction to Redis for .NET Developers.pdfStephen Lorello
 
Presentation of OrientDB v2.2 - Webinar
Presentation of OrientDB v2.2 - WebinarPresentation of OrientDB v2.2 - Webinar
Presentation of OrientDB v2.2 - WebinarOrient Technologies
 
ASP.Net 5 and C# 6
ASP.Net 5 and C# 6ASP.Net 5 and C# 6
ASP.Net 5 and C# 6Andy Butland
 
Zend Server Data Caching
Zend Server Data CachingZend Server Data Caching
Zend Server Data CachingEl Taller Web
 
Everything new with PHP 7.3
Everything new with PHP 7.3Everything new with PHP 7.3
Everything new with PHP 7.3Damien Seguy
 
Automating your php infrastructure with the zend server api
Automating your php infrastructure with the zend server apiAutomating your php infrastructure with the zend server api
Automating your php infrastructure with the zend server apiYonni Mendes
 
05 integrate redis
05 integrate redis05 integrate redis
05 integrate redisErhwen Kuo
 
Architecting queueslsp15
Architecting queueslsp15Architecting queueslsp15
Architecting queueslsp15Sandy Smith
 
TDD with Puppet Tutorial presented at Cascadia IT Conference 2014-03-07
TDD with Puppet Tutorial presented at Cascadia IT Conference 2014-03-07TDD with Puppet Tutorial presented at Cascadia IT Conference 2014-03-07
TDD with Puppet Tutorial presented at Cascadia IT Conference 2014-03-07garrett honeycutt
 

Similar a Redis modules 101 (20)

Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Redis Modules API - an introduction
Redis Modules API - an introductionRedis Modules API - an introduction
Redis Modules API - an introduction
 
Developing a Redis Module - Hackathon Kickoff
 Developing a Redis Module - Hackathon Kickoff Developing a Redis Module - Hackathon Kickoff
Developing a Redis Module - Hackathon Kickoff
 
[db tech showcase Tokyo 2014] B15: Scalability with MariaDB and MaxScale by ...
[db tech showcase Tokyo 2014] B15: Scalability with MariaDB and MaxScale  by ...[db tech showcase Tokyo 2014] B15: Scalability with MariaDB and MaxScale  by ...
[db tech showcase Tokyo 2014] B15: Scalability with MariaDB and MaxScale by ...
 
MySQL 5.7 in a Nutshell
MySQL 5.7 in a NutshellMySQL 5.7 in a Nutshell
MySQL 5.7 in a Nutshell
 
LA Ember.js Meetup, Jan 2017
LA Ember.js Meetup, Jan 2017LA Ember.js Meetup, Jan 2017
LA Ember.js Meetup, Jan 2017
 
Postgres Vienna DB Meetup 2014
Postgres Vienna DB Meetup 2014Postgres Vienna DB Meetup 2014
Postgres Vienna DB Meetup 2014
 
Orchestrating Redis & K8s Operators
Orchestrating Redis & K8s OperatorsOrchestrating Redis & K8s Operators
Orchestrating Redis & K8s Operators
 
Writing Redis Modules In Rust: Gavrie Philipson
Writing Redis Modules In Rust: Gavrie PhilipsonWriting Redis Modules In Rust: Gavrie Philipson
Writing Redis Modules In Rust: Gavrie Philipson
 
Building and Scaling Node.js Applications
Building and Scaling Node.js ApplicationsBuilding and Scaling Node.js Applications
Building and Scaling Node.js Applications
 
An Introduction to Redis for .NET Developers.pdf
An Introduction to Redis for .NET Developers.pdfAn Introduction to Redis for .NET Developers.pdf
An Introduction to Redis for .NET Developers.pdf
 
Wider than rails
Wider than railsWider than rails
Wider than rails
 
Presentation of OrientDB v2.2 - Webinar
Presentation of OrientDB v2.2 - WebinarPresentation of OrientDB v2.2 - Webinar
Presentation of OrientDB v2.2 - Webinar
 
ASP.Net 5 and C# 6
ASP.Net 5 and C# 6ASP.Net 5 and C# 6
ASP.Net 5 and C# 6
 
Zend Server Data Caching
Zend Server Data CachingZend Server Data Caching
Zend Server Data Caching
 
Everything new with PHP 7.3
Everything new with PHP 7.3Everything new with PHP 7.3
Everything new with PHP 7.3
 
Automating your php infrastructure with the zend server api
Automating your php infrastructure with the zend server apiAutomating your php infrastructure with the zend server api
Automating your php infrastructure with the zend server api
 
05 integrate redis
05 integrate redis05 integrate redis
05 integrate redis
 
Architecting queueslsp15
Architecting queueslsp15Architecting queueslsp15
Architecting queueslsp15
 
TDD with Puppet Tutorial presented at Cascadia IT Conference 2014-03-07
TDD with Puppet Tutorial presented at Cascadia IT Conference 2014-03-07TDD with Puppet Tutorial presented at Cascadia IT Conference 2014-03-07
TDD with Puppet Tutorial presented at Cascadia IT Conference 2014-03-07
 

Último

Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 

Último (20)

Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 

Redis modules 101

  • 1. Redis Modules TL;DR Dvir Volk, Senior Architect, Redis Labs
  • 2. So… Modules, huh? • I’ve been waiting 6 years • Will change Redis forever IMO • The key is the API concept
  • 3. What Modules Actually Are • Dynamically loaded libraries into redis • Extend redis with new commands • Written in C (C++ if you really insist) • Using a C API designed to isolate redis internals
  • 4. The Race For JS Modules is ON!
  • 5. What Modules Can’t Do (YET) • Register new data structures * • Override existing commands * • Block • Not the entire API of redis is accessible directly • All Coming Soon * Not completely true!
  • 6. Modules in Action 127.0.0.1:9875> MODULE LOAD example.so OK 127.0.0.1:9875> HSET foo bar baz (integer) 1 127.0.0.1:9875> HGETSET foo bar w00t! "baz" 127.0.0.1:9875> HGETSET foo bar wat? "w00t!"
  • 7. The Main API Layers High Level API ● Generic RedisCall ● Basically Lua on steroids Operational API ● Compose responses, examine call replies ● Memory Management Low Level API ● Selected parts of redis commands (L*, Z*) ● String DMA
  • 8. Main Building Blocks RedisModuleString* Memory managed strings for the module Opaque to the developer Args and replies RedisModuleCallReply* Returned from most calls Like the protocol can be: ● Strings ● Arrays ● Integers ● Errors ● Null RedisModuleKey* References to keys we are working with, mainly for the lower level API Acquired with Open Released automatically or with Close
  • 9. RedisModuleCtx * ● Redis’ execution context for a command ● Opaque to the module developer ● Passed to most functions ● Behind the scenes manages resources ○ Allocated Objects ○ Opened Keys ○ Automatic free at exit
  • 10. High Level API RedisModuleCallReply *rep = RedisModule_Call(ctx, "HGET", "cl", "foo", 1337);
  • 11. High Level API ● More or less like LUA’s API ● Generic RedisModule_Call ● Examine replies with RedisModule_CallReplyType ● Reply to the client with RedisModule_ReplyWith* ● Slower than lower level API, but flexible
  • 12. Low Level API ● MUCH faster
  • 13. Low Level API ● MUCH faster ● Hash Get/Set
  • 14. Low Level API ● MUCH faster ● Hash Get/Set ● ZSET operations
  • 15. Low Level API ● MUCH faster ● Hash Get/Set ● ZSET operations ● ZSET Iterators
  • 16. Low Level API ● MUCH faster ● Hash Get/Set ● ZSET operations ● ZSET Iterators ● String DMA / truncate
  • 17. Low Level API ● MUCH faster ● Hash Get/Set ● ZSET operations ● ZSET Iterators ● String DMA / truncate ● List push/pop
  • 18. Low Level API ● MUCH faster ● Hash Get/Set ● ZSET operations ● ZSET Iterators ● String DMA / truncate ● List push/pop ● Expire
  • 19. Low Level API ● MUCH faster ● Hash Get/Set ● ZSET operations ● ZSET Iterators ● String DMA / truncate ● List push/pop ● Expire ● More to come!
  • 20. String DMA ● Use Redis strings as raw memory ● Zero Copy Overhead ● Resize strings with RedisModule_Truncate ● BYODS - Bring Your Own Data Structure
  • 21. • Basic Module Template • Complete Documentation • Automating Boring Stuff • Argument Parsing • String Manipulation • Response Validation • Testing https://github.com/RedisLabs/RedisModulesSDK Shameless Plug: RedisModulesSDK
  • 22. Let’s Make a Module! HGETSET <key> <element> <newval>
  • 23. Step 1: Command Handler #include “redismodule.h” /* HGETSET <key> <element> <value> */ int HGetSetCmd(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { return REDISMODULE_OK; }
  • 24. Step 2: validate args /* HGETSET <key> <element> <value> */ int HGetSetCmd(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { if (argc != 4) { return RedisModule_WrongArity(ctx); } return REDISMODULE_OK; }
  • 25. Step 3: Auto Memory /* HGETSET <key> <element> <value> */ int HGetSetCmd(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { if (argc != 4) { return RedisModule_WrongArity(ctx); } RedisModule_AutoMemory(ctx); return REDISMODULE_OK; }
  • 26. Step 4: Making Calls! /* HGETSET <key> <element> <value> */ int HGetSetCmd(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { … RedisModuleCallReply *rep = RedisModule_Call(ctx, "HGET", "ss", argv[1], argv[2]); RMUTIL_ASSERT_NOERROR(rep) … }
  • 27. Step 4: MOAR CALLZ PLZ /* HGETSET <key> <element> <value> */ int HGetSetCmd(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { … RedisModuleCallReply *srep = RedisModule_Call(ctx, "HSET", "sss", argv[1], argv[2], argv[3]); REDIS_ASSERT_NOERROR(srep) return REDISMODULE_OK; }
  • 28. Step 5: Returning a reply /* HGETSET <key> <element> <value> */ int HGetSetCmd(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { … RedisModule_ReplyWithCallReply(ctx, rep); return REDISMODULE_OK; }
  • 29. Step 6: Initializing int RedisModule_OnLoad(RedisModuleCtx *ctx) { if (RedisModule_Init(ctx,"EXAMPLE",1,REDISMODULE_APIVER_1) == REDISMODULE_ERR) return REDISMODULE_ERR; if (RedisModule_CreateCmd(ctx,"HGETSET", HGetSetCommand, “write”, 1, 1, 1) == REDISMODULE_ERR) return REDISMODULE_ERR; return REDISMODULE_OK; }
  • 30. Step 6: Initializing int RedisModule_OnLoad(RedisModuleCtx *ctx) { if (RedisModule_Init(ctx,"EXAMPLE",1,REDISMODULE_APIVER_1) == REDISMODULE_ERR) return REDISMODULE_ERR; if (RedisModule_CreateCmd(ctx,"HGETSET", HGetSetCommand, “write”, 1, 1, 1) == REDISMODULE_ERR) return REDISMODULE_ERR; return REDISMODULE_OK; }
  • 31. • No special Linking required • Just #include “redismodule.h” Building and Makefile CFLAGS = -Wall -fPIC LDFLAGS = -shared -Bsymbolic -lc module.so: module.o $(LD) -o $@ module.o $(LDFLAGS)
  • 32. IT WORKS! 127.0.0.1:9875> MODULE LOAD example.so OK 127.0.0.1:9875> HSET foo bar baz (integer) 1 127.0.0.1:9875> HGETSET foo bar w00t! "baz" 127.0.0.1:9875> HGETSET foo bar wat? "w00t!"
  • 34. Low Level API: Example /* ZSUMRANGE <key> <startscore> <endscore> */ int ZsumRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { return REDISMODULE_OK; }
  • 35. Low Level API: Read Arguments int ZsumRange_RedisCommand(...) { double min, max; double sum = 0; if (MUtil_ParseArgs(argv, argc, 2, "dd", &min, &max) != REDISMODULE_OK) { RedisModule_WrongArity(ctx); } ... }
  • 36. Low Level API: Open The Key int ZsumRange_RedisCommand(...) { ... RedisModuleKey *k = RedisModule_OpenKey(ctx, argv[1], REDISMODULE_READ); if (RedisModule_KeyType(k) != REDISMODULE_KEYTYPE_ZSET){ return RedisModule_ReplyWithError(...); } }
  • 37. Low Level API: Iterate ZSET int ZsumRange_RedisCommand(...) { ... // Open The iterator RedisModule_ZsetFirstInScoreRange(k, min, max, 0, 0); while(!RedisModule_ZsetRangeEndReached(k)) { ... RedisModule_ZsetRangeNext(k); } RedisModule_ZsetRangeStop(k);
  • 38. Low Level API: Read Iterator Values while(!RedisModule_ZsetRangeEndReached(k)) { double score; RedisModuleString *ele = RedisModule_ZsetRangeCurrentElement(k, &score); RedisModule_FreeString(ctx, ele); sum += score; RedisModule_ZsetRangeNext(k); }
  • 39. Low Level API: Return the value /* ZSUMRANGE key startscore endscore */ int ZsumRange_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) { ... RedisModule_CloseKey(key); RedisModule_ReplyWithDouble(ctx, sum); return REDISMODULE_OK; }
  • 40. A Little Benchmark ● Sum the scores of 1,000,000 ZSET Elements ● Python client, Lua script, High/Low Level Modules ● Low Level API uses iterators ● The rest use ZRANGEBYSCORE