ehcache

net.sf.ehcache.util.counter
Interface Counter

All Known Subinterfaces:
SampledCounter, SampledRateCounter
All Known Implementing Classes:
CounterImpl, SampledCounterImpl, SampledCounterProxy, SampledRateCounterImpl, SampledRateCounterProxy

public interface Counter

A simple counter

Since:
1.7
Author:
Abhishek Sanoujam

Method Summary
 long decrement()
          Decrement the counter by 1
 long decrement(long amount)
          Decrement the counter by given amount
 long getAndSet(long newValue)
          Returns the value of the counter and sets it to the new value
 long getValue()
          Gets current value of the counter
 long increment()
          Increment the counter by 1
 long increment(long amount)
          Increment the counter by given amount
 void setValue(long newValue)
          Sets the value of the counter to the supplied value
 

Method Detail

increment

long increment()
Increment the counter by 1

Returns:
the value after incrementing

decrement

long decrement()
Decrement the counter by 1

Returns:
the value after decrementing

getAndSet

long getAndSet(long newValue)
Returns the value of the counter and sets it to the new value

Parameters:
newValue -
Returns:
Returns the old value

getValue

long getValue()
Gets current value of the counter

Returns:
current value of the counter

increment

long increment(long amount)
Increment the counter by given amount

Parameters:
amount -
Returns:
the value of the counter after incrementing

decrement

long decrement(long amount)
Decrement the counter by given amount

Parameters:
amount -
Returns:
the value of the counter after decrementing

setValue

void setValue(long newValue)
Sets the value of the counter to the supplied value

Parameters:
newValue -

ehcache

Copyright 2001-2017, Terracotta, Inc.