Class Counter


  • public final class Counter
    extends java.lang.Object
    Counter,encapsulate the incr/decr methods.
    • Constructor Summary

      Constructors 
      Constructor Description
      Counter​(MemcachedClient memcachedClient, java.lang.String key, long initialValue)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long addAndGet​(long delta)
      Add value and get the result
      long decrementAndGet()
      Decrease value by one
      boolean equals​(java.lang.Object obj)  
      long get()
      Get current value
      java.lang.String getKey()  
      int hashCode()  
      long incrementAndGet()
      Increase value by one
      void set​(long value)
      Set counter's value to expected.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • key

        private final java.lang.String key
      • initialValue

        private final long initialValue
    • Constructor Detail

      • Counter

        public Counter​(MemcachedClient memcachedClient,
                       java.lang.String key,
                       long initialValue)
    • Method Detail

      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • getKey

        public final java.lang.String getKey()
      • get

        public long get()
                 throws MemcachedException,
                        java.lang.InterruptedException,
                        java.util.concurrent.TimeoutException
        Get current value
        Returns:
        Throws:
        MemcachedException
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException
      • set

        public void set​(long value)
                 throws MemcachedException,
                        java.lang.InterruptedException,
                        java.util.concurrent.TimeoutException
        Set counter's value to expected.
        Parameters:
        value -
        Throws:
        MemcachedException
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException
      • incrementAndGet

        public long incrementAndGet()
                             throws MemcachedException,
                                    java.lang.InterruptedException,
                                    java.util.concurrent.TimeoutException
        Increase value by one
        Returns:
        Throws:
        MemcachedException
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException
      • decrementAndGet

        public long decrementAndGet()
                             throws MemcachedException,
                                    java.lang.InterruptedException,
                                    java.util.concurrent.TimeoutException
        Decrease value by one
        Returns:
        Throws:
        MemcachedException
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException
      • addAndGet

        public long addAndGet​(long delta)
                       throws MemcachedException,
                              java.lang.InterruptedException,
                              java.util.concurrent.TimeoutException
        Add value and get the result
        Parameters:
        delta -
        Returns:
        Throws:
        MemcachedException
        java.lang.InterruptedException
        java.util.concurrent.TimeoutException