Documentation ¶
Overview ¶
Package caslock implements a row lock mechanism for cassandra, based on lightweight transactions. It allows to lock an arbitrary number of rows, protecting them from concurrent access.
Usage:
l, err := caslock.Acquire(session, "keyspace", "table", 30 * time.Second, "rowKey1", "rowKey2") if err != nil { return err } defer l.Release()
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // LockColumn is the name of the column used to control row locks. It // must added to the desired column family before using caslock. LockColumn = "[lock]" // RetryTime is the time beteween retries when a row has been locked by // another process. RetryTime = 500 * time.Millisecond // Log is the logger used to register warnings and info messages. If it is nil, // no messages will be logged. Log *log.Logger )
Functions ¶
This section is empty.
Types ¶
type Lock ¶
type Lock struct {
// contains filtered or unexported fields
}
Lock represents a cassandra's row lock.
func Acquire ¶
func Acquire(session *gocql.Session, keyspace, table string, timeout time.Duration, rowKeys ...interface{}) (*Lock, error)
Acquire locks the rows in rowKeys on the table keyspace.table. The parameter timeout defines the minimum time that the rows will locked before being automatically released.
Click to show internal directories.
Click to hide internal directories.