Uploaded image for project: 'Spring Data Redis'
  1. Spring Data Redis
  2. DATAREDIS-874

Implement accumulate/update methods on RedisAtomicInteger, RedisAtomicLong, and RedisAtomicDouble

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: None
    • Fix Version/s: 2.2 M1 (Moore)
    • Component/s: Core
    • Labels:
      None

      Description

      Java 8 introduced a few methods to the AtomicInteger/AtomicLong classes, which would be useful to implement on the RedisAtomicInteger/RedisAtomicLong classes provided in spring-data-redis.

      They are primarily useful for doing CAS operations, leveraging custom functions (BinaryOperator/UnaryOperator) to generate the new value.

      I'm proposing the following new methods for RedisAtomicInteger:

      public int accumulateAndGet(int x, IntBinaryOperator accumulatorFunction);
      public int getAndAccumulate(int x, IntBinaryOperator accumulatorFunction);
      public int updateAndGet(IntUnaryOperator updateFunction);
      public int getAndUpdate(IntUnaryOperator updateFunction);

      And for RedisAtomicLong:

      public long accumulateAndGet(long x, LongBinaryOperator accumulatorFunction);
      public long getAndAccumulate(long x, LongBinaryOperator accumulatorFunction);
      public long getAndUpdate(LongUnaryOperator updateFunction);
      public long updateAndGet(LongUnaryOperator updateFunction);

      Does this sound acceptable? I'm planning to submit a new PR for this soon unless it's already being worked on by somebody else.

        Attachments

          Activity

            People

            • Assignee:
              mp911de Mark Paluch
              Reporter:
              gmacster Graham MacMaster
              Last updater:
              Christoph Strobl
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: