Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scala: Redis client implementation with Akka futures

I'm looking for Redis client implementation for Scala. The client should be async and non-blocking, using Akka futures. What I found more or less useful:

  1. https://github.com/derekjw/fyrie-redis
  2. https://github.com/debasishg/scala-redis

But both of them have their issues. First one uses old version of Akka, which causes compilation issues, second one uses scala.actors.Futures.future instead of Akka futures. I saw a conversation, which took place few months ago: groups.google.com/forum/#!msg/akka-user/EDKA2aTigho/_wWcNIz2O3wJ

But I failed to find any solution. Anyone had something similar?

Thanks for your answers.

like image 743
psisoyev Avatar asked Jan 31 '13 13:01

psisoyev


4 Answers

Here are a few new Scala Redis libraries that are Reactive (async + non-blocking):
https://github.com/debasishg/scala-redis-nb
https://github.com/etaty/rediscala
https://github.com/Livestream/scredis

like image 86
James Ward Avatar answered Nov 11 '22 13:11

James Ward


scala-redis is currently the best option. While it is a blocking client, some examples of asynchronous patterns are given in the README file. Also note that the library itself does not use scala.actors.Futures.future; only demo code in the spec (test code) and README does.

If you only need to store a few things in Redis, it's also possible to roll your own Redis client with a Spray.io IOBridge.

On a sidenote: Akka futures are already in Scala 2.10.0 and scala.actors is deprecated as of Scala 2.11.0. I'm not sure why scala-redis is using scala.actors even though it depends on Akka and Scala 2.10.0.

like image 23
praseodym Avatar answered Nov 11 '22 13:11

praseodym


There's a non-blocking client that returns Futures available as the finagle-redis module. Example usage here: https://github.com/twitter/finagle/blob/master/finagle-example/src/main/scala/com/twitter/finagle/example/redis/RedisClient.scala

A caveat: it currently returns Twitter Futures. You can use that to complete the Promise for an Akka Future; an example of that is on the first code example in the slides for Blake's NEScala talk: http://nescala.org/#t-8378162

People at Twitter say they'll have Twitter futures implement the 2.10 Future trait for API compatibility, when they move to 2.10.

The author of scala-redis sounded interested in porting it to use spray-io, in which case it would be non-blocking.

like image 37
pdxleif Avatar answered Nov 11 '22 13:11

pdxleif


There is also scredis which is a complete, non-blocking and blazing fast Scala Redis client built on top of Akka IO. It is extensively used in production at Livestream.

like image 1
Alexandre Curreli Avatar answered Nov 11 '22 15:11

Alexandre Curreli