1 Reply Latest reply on Sep 12, 2013 10:07 AM by moia

    Hotrod Client support for atomic operations

    infinifan

      Hi,

       

      My application is using Infinispan 5.3.0.Final.

       

      I'm using Infinispans hot client client to connect with a remote cache. I would like to use the cache to persist counters. However I'm not sure what is the best way to use the remote cache to atomically increment these counters in a muti-threaded environment.

      Is there some way of performing a Redis "INCR" type operation ?

       

      Or should I configure transactions and locking via my clustered.xml file ?

       

      Thanks,

      Jack.

        • 1. Re: Hotrod Client support for atomic operations
          moia

          Jack,

          I currently use optimistic locking mechanism to do this kind of operations - basically you get versioned data from the remote cache, increment it and use replace operation - this will fail if the value has changed since you read it, then you may repeat the operation. I use putIfAbsent, getVersioned and replaceWithVersion operations.

           

          This works fine, when the elements are small and transport is fast. We are currently facing a problem, where we have large elements and want to increment single counters within them. I am looking for an alternative - for now the Distributed Execution Framework seems perfect for this, only I haven't found a way yet to access it via hot rod or other remote protocol.

           

          Best regards,

          Mikolaj