store

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2017 License: GPL-3.0 Imports: 27 Imported by: 1

Documentation

Overview

Copyright 2015 PingCAP, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	OWN lockType = 1 + iota
	RW
	W
)

Variables

View Source
var (
	// TxnEntrySizeLimit is limit of single entry size (len(key) + len(value)).
	TxnEntrySizeLimit = 6 * 1024 * 1024
	// TxnEntryCountLimit  is limit of number of entries in the MemBuffer.
	TxnEntryCountLimit uint64 = 300 * 1000
	// TxnTotalSizeLimit is limit of the sum of all entry size.
	TxnTotalSizeLimit = 100 * 1024 * 1024
)

Those limits is enforced to make sure the transaction can be well handled by TiKV.

Functions

func NewMemDbBuffer

func NewMemDbBuffer() *memDbBuffer

NewMemDbBuffer creates a new memDbBuffer.

func StringToLogicSymbol

func StringToLogicSymbol(s string) (logicSymbol, bool)

StringToLogicSymbol used to conversion string to logicSymbol

Types

type KVStore

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

KVStore struct

func NewKVStore

func NewKVStore(backend string, servers []string, keyspace string) (*KVStore, error)

NewKVStore used to init a KVStore struct

func (*KVStore) Delete added in v0.2.6

func (k *KVStore) Delete(obj interface{}) (err error)

Delete from kv store

func (*KVStore) Get added in v0.2.6

func (k *KVStore) Get(in interface{}) (lastIndex uint64, err error)

Get obj from kv store, fill found data into give obj and return lastIndex

func (*KVStore) IsLocked

func (k *KVStore) IsLocked(obj interface{}, lockType lockType) (r bool)

IsLocked return true if have a lock key in kv store

func (*KVStore) Set added in v0.2.6

func (k *KVStore) Set(currentObj interface{}, lastIndex uint64, previousObj interface{}) error

Set obj to kv store, if lastIndex and previousObj is not nil, it will use atomicPut

func (*KVStore) WatchLock

func (k *KVStore) WatchLock(obj interface{}, stopCh chan struct{}) (chan string, error)

WatchLock watch lock path, put any change key into chan

func (*KVStore) WhoLocked

func (k *KVStore) WhoLocked(obj interface{}, lockType lockType) (v string)

WhoLocked return the lock's value

type Key

type Key []byte

Key type

type LockOption added in v0.2.6

type LockOption struct {
	Global   bool          // if true, the locker can access by any goroutine
	LockType lockType      // lock type
	TimeOut  time.Duration // if no lock in this time is successful return timeout
}

type LockerChain

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

func NewLockerChain

func NewLockerChain(owner string, store *KVStore) *LockerChain

new lockerchain

func (*LockerChain) AddLocker

func (l *LockerChain) AddLocker(obj interface{}, lockoption *LockOption) error

AddLocker, lock a obj and save locker into LockerChain if global is true, all goroutine can access this lock, if not only the goroutine created it can access it.

func (*LockerChain) HaveIt

func (l *LockerChain) HaveIt(obj interface{}, lockType lockType) bool

HaveIt, return true if find the obj's Locker in LockerChain

func (*LockerChain) ReleaseAll

func (l *LockerChain) ReleaseAll()

ReleaseAll release all lock

func (*LockerChain) ReleaseLocker

func (l *LockerChain) ReleaseLocker(obj interface{}, global bool, lockType lockType) error

ReleaseLocker release a lock if global is true, all goroutine can access this lock, if not only the goroutine created it can access it.

func (*LockerChain) Stop

func (l *LockerChain) Stop()

release all lock and stop renew process

type MemStore

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

MemStore used to cache job in local memory

func NewMemStore

func NewMemStore() *MemStore

NewMemStore init a MemStore and start a goroutine handle expired key

func (*MemStore) Delete added in v0.2.6

func (m *MemStore) Delete(key string) error

func (*MemStore) Get

func (m *MemStore) Get(key string, out interface{}) (err error)

func (*MemStore) Release

func (m *MemStore) Release()

Release used to stop MemStore

func (*MemStore) Set

func (m *MemStore) Set(key string, in interface{}, ttl time.Duration) (err error)

type SQLStore

type SQLStore struct {
	Err error // error
	// contains filtered or unexported fields
}

SQLStore database obj

func NewSQLStore

func NewSQLStore(backend, dsn string) (*SQLStore, error)

NewSQLStore init a SQLStore struct

func (*SQLStore) Close

func (s *SQLStore) Close() error

Close database connect

func (*SQLStore) Create

func (s *SQLStore) Create(obj interface{}) *SQLStore

Create func perform create in database

func (*SQLStore) Delete

func (s *SQLStore) Delete(obj interface{}) *SQLStore

Delete func perform delete

func (*SQLStore) Find

func (s *SQLStore) Find(out interface{}) *SQLStore

Find func perform find in database

func (*SQLStore) Migrate

func (s *SQLStore) Migrate(drop bool, valus ...interface{}) error

Migrate auto migrate table struct

func (*SQLStore) Model

func (s *SQLStore) Model(obj interface{}) *SQLStore

Model set the model to be manipulated

func (*SQLStore) Modify

func (s *SQLStore) Modify(obj interface{}) *SQLStore

Modify func perform modify

func (*SQLStore) PageCount

func (s *SQLStore) PageCount(out interface{}) *SQLStore

PageCount func cal max page num

func (*SQLStore) PageNum

func (s *SQLStore) PageNum(i int) *SQLStore

PageNum which page need scan into result set

func (*SQLStore) PageSize

func (s *SQLStore) PageSize(i int) *SQLStore

PageSize set page size

func (*SQLStore) Where

func (s *SQLStore) Where(obj interface{}) *SQLStore

Where build where condition, can be a obj or SearchContion

type SearchCondition

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

SearchCondition save search condition

func NewSearchCondition

func NewSearchCondition(conditions, links []string) (*SearchCondition, error)

NewSearchCondition serialized user input generated SearchCondition

Jump to

Keyboard shortcuts

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