Documentation ¶
Index ¶
- func ExtendLock(rc redis.Conn, key string, value string, expiration int) error
- func GrabLock(rc redis.Conn, key string, value string, expiration int) (bool, error)
- func ReleaseLock(rc redis.Conn, key string, value string) error
- func StartCron(quit chan bool, rp *redis.Pool, name string, interval time.Duration, ...)
- type Function
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtendLock ¶ added in v0.0.5
ExtendLock extends our lock expiration by the passed in number of seconds
func GrabLock ¶
GrabLock grabs the passed in lock from redis in an atomic operation. It returns whether the lock was available and acquired
func ReleaseLock ¶
ReleaseLock releases the passed in lock, returning any error encountered while doing so. It is not considered an error to release a lock that is no longer present
func StartCron ¶ added in v0.0.5
func StartCron(quit chan bool, rp *redis.Pool, name string, interval time.Duration, cronFunc Function)
StartCron calls the passed in function every minute, making sure it acquires a lock so that only one process is running at once. Note that across processes crons may be called more often than duration as there is no inter-process coordination of cron fires. (this might be a worthy addition)