acrosa / scala-redis Goto Github PK
View Code? Open in Web Editor NEWA scala library for connecting to a redis server, or a cluster of redis nodes using consistent hashing on the client side.
License: MIT License
A scala library for connecting to a redis server, or a cluster of redis nodes using consistent hashing on the client side.
License: MIT License
Thanks for the library. Do you have plans to implement pubsub support in scala-redis? Akka seems to have a nice implementation, but having it in a small and simple lib like this would be great.
results don't seem to come back in the right order. Looked like results were just put in a regular Set.
scala> val r= new com.redis.Redis("localhost",6379)
r: com.redis.Redis = localhost:6379 connected:true
scala> r.set("testkey","sdfsdfdsf")
res1: Boolean = true
scala> r.get("testkey")
res2: Option[String] = Some(9)
Hi,
I was trying out your scala-redis library for my project. I encountered problems when inserting unicode strings into redis database.
Some of the unicode strings are not inserted at all, some of them are getting inserted but only a part of it. I tried with my scala interpreter too. At one point it just give array index out of bounds exception or it hangs (infinite loop or something). I have dumped the errors below.
Please let me know, if you have any suggestions or fixes for this.
I appreciate any kind of input.
Thank you.
Sincerely,
Anandan Rangasamy.
Here's the dump:
//one part of it
scala> val r = new Redis()
r: com.redis.Redis = localhost:6379 connected:true
scala> r.pushHead("Aäko","Aäkon Këëtrëh")
res7: Boolean = true
scala> r.listLength("Aäko")
res8: Option[Int] = None
//another one
scala> val r = new Redis()
r: com.redis.Redis = localhost:6379 connected:true
scala> r.listLength("Aäko")
res6: Option[Int] = Some(2)
scala> r.listRange("Aäko",0,1)
java.lang.ArrayIndexOutOfBoundsException: 1
at com.redis.SocketOperations$class.bulkReply(SocketOperations.scala:152)
at com.redis.Connection.bulkReply(Connection.scala:8)
at com.redis.SocketOperations$$anonfun$listReply$1.apply(SocketOperations.scala:171)
at com.redis.SocketOperations$$anonfun$listReply$1.apply(SocketOperations.scala:170)
at scala.Range.foreach(Range.scala:44)
...
scala> r.listRange("Aal",0,1)
res1: Option[List[String]] = Some(List(Aal, Aalacho))
scala> r.listRange("Aän",0,1)
res2: Option[List[String]] = None
scala> r.listRange("Aan",0,-1)
res3: Option[List[String]] = Some(List(Aan, Aantar Lee Coates, Aantonio ZZ))
scala> r.listRange("Aäkon",0,-1)
java.lang.ArrayIndexOutOfBoundsException: 1
at com.redis.SocketOperations$class.bulkReply(SocketOperations.scala:152)
at com.redis.Connection.bulkReply(Connection.scala:8)
at com.redis.SocketOperations$$anonfun$listReply$1.apply(SocketOperations.scala:171)
at com.redis.SocketOperations$$anonfun$listReply$1.apply(SocketOperations.scala:170)
at scala.Range.foreach(Range.scala:44)
// anothe one, where it hangs (probably an infinite loop or something)
scala> import com.redis._
import com.redis._
scala> val r = new Redis()
r: com.redis.Redis = localhost:6379 connected:true
scala> r.listLength("Aäkon1")
res0: Option[Int] = Some(1)
scala> r.listRange("Aäkon1",0,-1)
Binary data is not supported in pub/sub mode.
test code:
#2.1 Subscriber (scala)
val client = new RedisClient("localhost", 6379)
client.subscribe("hello")((msg: PubSubMessage) => {
println("rcv from channel:", msg)
msg match{
case m:M => {
println("rcv", m.message)
dumpBytes(m.message.getBytes("iso-8859-1"))
}
case _ => {println("Unknown...")}
}
})
2.2 Publisher (by jedis)
byte[] data = {0x01,0x02,(byte) 0xff};
Jedis jedis = new Jedis("localhost");
Is there anyone who can give me a suggestion?
Thanks!
@acrosa https://github.com/debasishg/scala-redis is maintained, https://github.com/acrosa/scala-redis/ is not.
You should probably direct people to the fork.
import com.redis._;
object GetFailsTest extends Application {
val r = new Redis("localhost", 6379)
r.set("key", "some value")
println(r.get("key"))
println(r.get("key").get)
}
I believe that this code should print:
Some("some value")
"some value"
Instead it prints:
None
10
I've compiled with scala-2.7.7 and am running against Redis 2.2.0.
If I try
val redisClient = RedisClient(endpoint)
redisClient.auth("pwd")
I get an exception
at akka.pattern.AskableActorRef$.ask$extension(AskSupport.scala:136)
at com.redis.api.KeyOperations$class.auth(KeyOperations.scala:112)
at com.redis.api.RedisOps.auth(RedisOps.scala:7)
I get invalid results using the keys command. Looks like the results do not get parsed correctly. I'm using redis 2.0.0. Is that supported? Here is a test
@test
def keysIsBroke {
Conn.redis.setAdd("fo1", "1")
Conn.redis.setAdd("fo2", "2")
val result = Conn.redis.keys("fo*")
assertEquals(2, result.get.size)
}
Is this driver threadsafe? Can I safely access an instance of RedisClient from multiple Actors? I seem to be getting deadlocks immediately after executing a method on RedisClient. I'm a bit new to Scala so forgive me if this is a bad question.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.