jedis icon indicating copy to clipboard operation
jedis copied to clipboard

Safe async movement

Open andreasdc opened this issue 3 years ago • 5 comments

What movement is safe async? Is reading or publishing safe in async?

andreasdc avatar Apr 20 '22 02:04 andreasdc

@andreasdc Could you please elaborate your question?

sazzad16 avatar May 28 '22 13:05 sazzad16

@andreasdc Could you please elaborate your question?

For example it's not safe to have saving async, because my database was broken often. So my question is what's safe to do async, for example getting keys or publishing?

andreasdc avatar May 28 '22 13:05 andreasdc

Hi @andreasdc any chance you can give an example of a command or commands that were causing you an issue? A code sample would be a great place to start.

chayim avatar May 29 '22 05:05 chayim

Hi @andreasdc any chance you can give an example of a command or commands that were causing you an issue? A code sample would be a great place to start.

What do you mean? I often use hset, hget, problem with messed database I had long time ago, but I saw that jedis shouldn't be accessed async. I just found this information in an article: "Jedis is all synchronous with the exception of pipelines. Pipelines allow asynchronous usage of Redis but, unfortunately, cannot be used alongside clustering." (https://redis.com/blog/jedis-vs-lettuce-an-exploration/)

andreasdc avatar May 29 '22 08:05 andreasdc

@andreasdc Thanks for sharing. There are things that have been changed. Here a few points:

  • ONLY the Jedis class shouldn't be accessed async. But there are other classes.
  • JedisPool allows async operations[1].
  • Newly introduced JedisPooled does almost the same thing in a much more convenient way.
  • JedisCluster allows async operations[1] in cluster mode.
  • Newly introduced ClusterPipeline allows pipelining in cluster mode.

Note: [1] not to be confused with async socket operations.

sazzad16 avatar May 29 '22 10:05 sazzad16