caslock

package module
v0.0.0-...-3f6dad3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2015 License: BSD-3-Clause Imports: 5 Imported by: 0

README

CasLock GoDoc

Description

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()

Installation

go get github.com/jroimartin/caslock

More information

godoc github.com/jroimartin/caslock

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.

func (*Lock) Release

func (l *Lock) Release() error

Release releases the lock.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL