Added methods to increment and decrement key values for RedisCache with redis atomic methods

Merged Aalekh Jain requested to merge redis-incr-decr into master

The following methods are added in RedisCache class

1. public Long increment(K key);
2. public Long incrementBy(K key, long amount);
3. public Long decrement(K key);
4. public Long decrementBy(K key, long amount);

This allows for using the atomic methods to increment/decrement a key present in redis cache. This is used in order to prevent race conditions while updating the integer value of a key present in redis cache.

Without these methods, the flow for incrementing/decrementing the value would usually be something like -

Integer value = redisCache.get(key);
redisCache.put(key, value + amount);

Note that this will result into race conditions when multiple increments/decrements take place.

One such scenarios is encountered in workflow ingestion service in the following MR: osdu/platform/data-flow/ingestion/ingestion-workflow!199 (merged) hence these methods are needed.

cc: @kibattul , @vineethguna, @harshit283

Merge request reports