You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Th following Transaction will never commit, promises deadlock! That 's absolutely not acceptable.
objectExampleTransactionextendsApp {
implicitvalakkaSystem= akka.actor.ActorSystem()
valredis=RedisClient("192.168.0.8", 6379)
varkeyX="x"varkeyY="y"varkeySum="sum"//init values of x and yvarsetX= redis.set(keyX, 101)
varsetY= redis.set(keyY, 103)
for {
setXStatus <- setX
setYStatus <- setY
} yield {
assert(setXStatus)
assert(setYStatus)
valredisTransaction= redis.transaction()
redisTransaction.watch(keyX)
redisTransaction.watch(keyY)
varkeyXFuture= redisTransaction.get(keyX);
varkeyYFuture= redisTransaction.get(keyY);
varr=for {
x <- keyXFuture
y <- keyYFuture
} yield {
varsum=ParseNumber.parseInt(x.getOrElse(ByteString("-1"))) +ParseNumber.parseInt(y.getOrElse(ByteString("-1")))
println("set(sum, x + y)|(x+y)="+ sum)
redisTransaction.set(keySum, sum)
redisTransaction.exec()
}
Await.result(r, 10 seconds)
}
Thread.sleep(1000*10)
akkaSystem.shutdown()
}
Th following Transaction should not commit since watched keys has been changed. But it commit normally. That 's absolutely not acceptable.
objectExampleTransactionextendsApp {
implicitvalakkaSystem= akka.actor.ActorSystem()
valredis=RedisClient("192.168.0.8", 6379)
valanotherRedis=RedisClient("192.168.0.8", 6379)
varkeyX="x"varkeyY="y"varkeySum="sum"//init value of x and yvarsetX= redis.set(keyX, 101)
varsetY= redis.set(keyY, 103)
for {
setXStatus <- setX
setYStatus <- setY
} yield {
assert(setXStatus)
assert(setYStatus)
valredisTransaction= redis.transaction()
redisTransaction.watch(keyX)
redisTransaction.watch(keyY)
varkeyXFuture= redis.get(keyX);
varkeyYFuture= redis.get(keyY);
//x and y modified by anotherRedis client
anotherRedis.set(keyX, -101)
anotherRedis.set(keyY, -103)
Thread.sleep(1000)
varr=for {
x <- keyXFuture
y <- keyYFuture
} yield {
varsum=ParseNumber.parseInt(x.getOrElse(ByteString("-1"))) +ParseNumber.parseInt(y.getOrElse(ByteString("-1")))
println("set(sum, x + y)|(x+y)="+ sum)
redisTransaction.set(keySum, sum)
redisTransaction.exec()
}
Await.result(r, 10 seconds)
}
Thread.sleep(1000*10)
akkaSystem.shutdown()
}
Hope that Transaction should be fully supported. I think Transaction should be implemented just like implemention of the blocking commands on the Lists.
Thanks & Best Regards!
The text was updated successfully, but these errors were encountered:
dawnbreaks
changed the title
Transaction is working as expected
Transaction is not working as expected
Apr 28, 2015
I kind of cheated the implementation of transaction. It's more like a batch of commands.
The rediscala watch command is kind of useless in 99% of case (because all the transaction commands are sent in one batch).
The best way would be to add a blocking transaction, however the transaction is "deprecated" for redis server, so I did not care much.
Lua script is the way to go.
Th following Transaction will never commit, promises deadlock! That 's absolutely not acceptable.
Th following Transaction should not commit since watched keys has been changed. But it commit normally. That 's absolutely not acceptable.
Hope that Transaction should be fully supported. I think Transaction should be implemented just like implemention of the blocking commands on the Lists.
Thanks & Best Regards!
The text was updated successfully, but these errors were encountered: