Documentation ¶
Overview ¶
Package rediscounter provides a counter that stores its value in a redis server
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RedisCounter ¶
type RedisCounter struct {
// contains filtered or unexported fields
}
RedisCounter represents a counter that stores its value in redis
func NewCounter ¶
func NewCounter(raddr, rpass, rkey string, rdb int) (*RedisCounter, error)
NewCounter creates a RedisCounter with the provided connection details.
"raddr" format should be host:port
"rpass" can be set to "" if no password authentication is required.
func (*RedisCounter) DecrBy ¶
func (rc *RedisCounter) DecrBy(a int64) (int64, error)
DecrBy decreases the counter's value by "a" amount and reports the resulting value. The counter's value cannot go below 0.
func (*RedisCounter) Get ¶
func (rc *RedisCounter) Get() (int64, error)
Get returns the current value of the counter
func (*RedisCounter) IncrBy ¶
func (rc *RedisCounter) IncrBy(a int64) (int64, error)
IncrBy increases the counter's value by "a" amount and reports the resulting value
func (*RedisCounter) RedisHealth ¶
func (rc *RedisCounter) RedisHealth() error
RedisHealth checks the redis server connection using PING
func (*RedisCounter) Reset ¶
func (rc *RedisCounter) Reset() (int64, error)
Reset sets the counter value to 0. It will allways return 0 so use error to determine if successful.
Directories ¶
Path | Synopsis |
---|---|
Command console starts a console client that implements the rediscounter package.
|
Command console starts a console client that implements the rediscounter package. |
Command webcounter starts a web server that implements the rediscounter package.
|
Command webcounter starts a web server that implements the rediscounter package. |