Announcement Announcement Module
Collapse
No announcement yet.
DefaultRedisSet in Spring Redis Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • DefaultRedisSet in Spring Redis

    I am using Spring-data-redis 1.0.4.RELEASE version. I see in DefaultRedisSet class, write methods like add, remove also calls checkResult method and hence throws IllegalStateException when used within multi-exec. My understanding is these methods are not trying to read anything from DB and hence should be allowed to used in multi-exec. If my use case needs to use DefaultRedisSet or DefaultRedisZSet's add or remove method within multi-exec, how should it be done.

    thanks,
    venkat

  • #2
    DefaultRedisSet add/remove can't be used in a pipeline or transaction primarily because it technically can't fulfill the Set interface contract of returning the boolean indicating success/fail of the operations (since all return values are null in those cases).

    Right now, the best way to do ops in a transaction is through RedisTemplate.execute() with a SessionCallback. Then you could call the add/remove operations directly on RedisOperations.boundSetOps(). How are you executing the transaction currently? What are the reasons for using DefaultRedisSet?

    Comment


    • #3
      Thanks. That explains why it was not working. And also I followed your suggestion and now it works under multi.

      Comment

      Working...
      X