Git Product home page Git Product logo

Comments (5)

debasishg avatar debasishg commented on July 28, 2024 1

Have a look at https://github.com/debasishg/scala-redis/blob/master/src/main/scala/com/redis/RedisClient.scala#L68 .. pipeline supports pipelining with transactions. Without transactions, pipelining is supported with pipelineNoMulti .. https://github.com/debasishg/scala-redis/blob/master/src/main/scala/com/redis/RedisClient.scala#L119 ..

Hope this helps.

from scala-redis.

montaro avatar montaro commented on July 28, 2024

Thanks, I could find a sample also in the test cases https://github.com/debasishg/scala-redis/blob/master/src/test/scala/com/redis/PipelineSpec.scala

However, my problem is that I want to execute 3 commands, the result of the first command should be the input for the successor 2 commands, when I tried this, the result of the first command resulted in "NullPointerException":

val result = redisClient.pipeline { c =>
  c.rpush(subscribersList, userData) match {
    case x @ Some(i) =>
      c.set(email, i)
      c.set(token, i)
      x
    case None => None
  }
}

Also what is the return of this pipeline function, what is the Option[List[Any]]?

Thanks,

from scala-redis.

debasishg avatar debasishg commented on July 28, 2024

Thanks for reporting .. will take a look over the weekend .. Will it be possible to give a failing test case which I can run and see the problem ?

from scala-redis.

debasishg avatar debasishg commented on July 28, 2024

I don't think you can do arbitrary logic within a redis transaction. And redid returns a list containing the execution result of each of them. I think you can have an equivalent effect with the following ..

describe("pipeline5") {
  it("should do pipelined commands") {
    val res = 
      r.rpush("subscribersList", "subs1") match {
        case x @ Some(i) =>
          r.pipeline { p =>
            p.set("email", i)
            p.set("token", i)
            p.llen("subscribersList")
          }.get
        case None => List()
      }
    println(res)
  }
}

and this will print List(true, true, Some(1))

from scala-redis.

montaro avatar montaro commented on July 28, 2024

Thanks a lot, I already went ti this approach in temporary basis, however after your confirmation, I will stick to it, thanks a gain.

from scala-redis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.