'Sync jedis pipeline peridically

I am working on a project where I need to write a stream of data to redis. I am using jedis clustered client with pipeline. The stream rate could be very fluctuating. So instead of syncing the pipeline say after every 100 records, I also want to sync it every 1 second. What would be a cleaner approach to achieve this.

  • As jedis is not thread safe, I guess using a scheduler/Timer (which uses a different Thread) is not safe

Really appreciate any suggestions/thoughts. Thank you!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source