Module resty.riak.counter
Riak counter object.
Can only be used with resty.riak created client. These are generally just wrappers around the low level resty.riak.client functions
Functions
new (bucket, key) | Create a new riak counter. |
value (self) | Get the value of the counter |
decrement (self, amount) | Decrement the counter |
increment (self, amount) | Increment the counter |
decrement_and_return (self, amount) | Decrement the counter and return its new value |
increment_and_return (self, amount) | Increment the counter and return its new value |
Functions
- new (bucket, key)
-
Create a new riak counter. This does not change anything in riak, it only sets up a Lua object.
Generally, resty.riak.bucket.counter
is prefered.
Parameters:
- bucket resty.riak.bucket
- key string
Returns:
- value (self)
-
Get the value of the counter
Parameters:
- self resty.riak.counter
Returns:
-
number
- decrement (self, amount)
-
Decrement the counter
Parameters:
- self resty.riak.counter
- amount number the amount to decrement the counter by
Returns:
-
boolean
- increment (self, amount)
-
Increment the counter
Parameters:
- self resty.riak.counter
- amount number the amount to increment the counter by
Returns:
-
boolean
- decrement_and_return (self, amount)
-
Decrement the counter and return its new value
Parameters:
- self resty.riak.counter
- amount number the amount to decrement the counter by
Returns:
-
number
- increment_and_return (self, amount)
-
Increment the counter and return its new value
Parameters:
- self resty.riak.counter
- amount number the amount to decrement the counter by
Returns:
-
number