[Announce] Build your Redis 4.0 modules in JavaScript with Cthulhu

34 views
Skip to first unread message

Marco Cecconi

unread,
Jul 23, 2017, 12:31:51 PM7/23/17
to Redis DB
I've had the pleasure of working a bit with Salvatore for the past few months learning the ropes of Redis and C, and one of the results of this collaboration is Cthulhu, a JavaScript interpreter for Redis. Basically, it allows you to write a Redis module in JavaScript. The Redis module API is supported and exposed through an object oriented interface.
You can get started by following the super simple instructions on github.
What can you do with Cthulhu? For example, you can manipulate any object in the Redis DB. For example, here's how to create a function to delete the top values of a Sorted Set:

function DeleteTop(name, num) { 
 var set = new Redis.SortedSet(name);
 var i = 0; var range = set.getRange();
 range.each(function(elem){
   if (i++<num) {
     set.remove(elem.key);
   }
 });
}

You can put this in a file called deleteTop.js, load it with cthulhu into Redis and you will have a new command available: INVOKE DeleteTop <name> <num>.


I'm looking for feedback, bug reports but also feature requests. If you find this useful, fantastic! If you want to help, that'd be awesome!

Antônio Guilherme Ferreira Viggiano

unread,
Jul 24, 2017, 10:26:39 AM7/24/17
to Redis DB
Hey, very nice module.

As I have stated on another thread, I guess one of the reasons we aren't seeing many redis modules is that not everyone is familiar with C.
I think your project helps to fill that gap, so congratulations!

Perhaps you could add more tests and examples (you can't get enough of them), a CI, and some performance benchmarks. 
Lastly and totally opinionated, I find the project's name slick but difficult to pronounce. Most modules stick with "redis-projectname", so I guess "redis-javascript" would be better (I hope this is one of those "drop the the" comments, don't get me wrong)
Reply all
Reply to author
Forward
0 new messages