db

package
v0.0.0-...-930013b Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2016 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//Dockyard Data Index
	GLOBAL_REPOSITORY_INDEX = "GLOBAL_REPOSITORY_INDEX"
	GLOBAL_IMAGE_INDEX      = "GLOBAL_IMAGE_INDEX"
	GLOBAL_TARSUM_INDEX     = "GLOBAL_TARSUM_INDEX"
	GLOBAL_TAG_INDEX        = "GLOBAL_TAG_INDEX"
	GLOBAL_COMPOSE_INDEX    = "GLOBAL_COMPOSE_INDEX"
	//Sail Data Index
	GLOBAL_USER_INDEX         = "GLOBAL_USER_INDEX"
	GLOBAL_ORGANIZATION_INDEX = "GLOBAL_ORGANIZATION_INDEX"
	GLOBAL_TEAM_INDEX         = "GLOBAL_TEAM_INDEX"
	//Wharf Data Index
	GLOBAL_ADMIN_INDEX = "GLOBAL_ADMIN_INDEX"
	GLOBAL_LOG_INDEX   = "GLOBAL_LOG_INDEX"
)

Variables

View Source
var (
	Client *redis.Client
)

Functions

func Get

func Get(obj interface{}, key string) (err error)

func InitDB

func InitDB(addr, passwd string, db int64) error

func Key

func Key(object string, keys ...string) (result string)

func Save

func Save(obj interface{}, key string) (err error)

Types

type Lock

type Lock struct {
	// contains filtered or unexported fields
}

func NewLock

func NewLock(client *redis.Client, key string, opts *LockOptions) *Lock

NewLock creates a new distributed lock on key

func ObtainLock

func ObtainLock(client *redis.Client, key string, opts *LockOptions) (*Lock, error)

ObtainLock is a shortcut for NewLock().Lock()

func (*Lock) IsLocked

func (l *Lock) IsLocked() bool

IsLocked returns true if a lock is acquired

func (*Lock) Lock

func (l *Lock) Lock() (bool, error)

Lock applies the lock, don't forget to defer the Unlock() function to release the lock after usage

func (*Lock) Unlock

func (l *Lock) Unlock() error

Unlock releases the lock

type LockOptions

type LockOptions struct {
	// The maximum duration to lock a key for
	// Default: 5s
	LockTimeout time.Duration

	// The maximum amount of time you are willing to wait to obtain that lock
	// Default: 0 = do not wait
	WaitTimeout time.Duration

	// In case WaitTimeout is activated, this it the amount of time you are willing
	// to wait between retries.
	// Default: 100ms, must be at least 10ms
	WaitRetry time.Duration
}

Jump to

Keyboard shortcuts

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