def count()

in clay/stats.py [0:0]


def count(key, n, sample=1.0):
    '''
    Increment a counter by n, or decrement if n is negative.

    :param key: The key to increment by the count
    :type key: string
    :param n: The number to increment by
    :type n: integer
    :param sample: Optional sample rate to scale the counter by. Must be a
                   float between 0.0 and 1.0. Defaults to 1.0
    :type sample: float
    '''
    if sample == 1.0:
        return connection.send('%s:%i|c' % (key, n))
    else:
        return connection.send('%s:%i|c|@%f' % (key, n, sample))