// Copyright 2014 Wandoujia Inc. All Rights Reserved. // Licensed under the MIT (MIT-LICENSE.txt) license. package rpdb import ( "container/list" "sync" "github.com/wandoulabs/redis-port/pkg/libs/errors" "github.com/wandoulabs/redis-port/pkg/libs/log" "github.com/wandoulabs/rpdb/pkg/store" ) var ( ErrClosed = errors.Static("rpdb has been closed") ) type Rpdb struct { mu sync.Mutex db store.Database splist list.List itlist list.List serial uint64 } func New(db store.Database) *Rpdb { return &Rpdb{db: db} }
// Copyright 2014 Wandoujia Inc. All Rights Reserved. // Licensed under the MIT (MIT-LICENSE.txt) license. package rpdb import ( "bytes" "github.com/wandoulabs/redis-port/pkg/libs/errors" "github.com/wandoulabs/redis-port/pkg/rdb" "github.com/wandoulabs/rpdb/pkg/store" ) var ( ErrNoSuchList = errors.Static("no such list") ErrOutOfRange = errors.Static("index out of range") ) type listRow struct { *rpdbRowHelper Lindex int64 Rindex int64 Index int64 Value []byte } func newListRow(db uint32, key []byte) *listRow { o := &listRow{} o.lazyInit(newRpdbRowHelper(db, key, ListCode)) return o
// Copyright 2014 Wandoujia Inc. All Rights Reserved. // Licensed under the MIT (MIT-LICENSE.txt) license. package rpdb import ( "fmt" "github.com/wandoulabs/redis-port/pkg/libs/errors" "github.com/wandoulabs/redis-port/pkg/libs/log" "github.com/wandoulabs/rpdb/pkg/store" ) var ( ErrMetaKey = errors.Static("invalid meta key") ErrDataKey = errors.Static("invalid data key") ErrNotMatched = errors.Static("unmatched raw bytes") ErrObjectCode = errors.Static("invalid object code") ErrObjectValue = errors.Static("invalid object value") ErrNotString = errors.Static("not string") ErrNotHash = errors.Static("not hash") ErrNotList = errors.Static("not list") ErrNotZSet = errors.Static("not zset") ErrNotSet = errors.Static("not set") ) func EncodeMetaKey(db uint32, key []byte) []byte { if len(key) == 0 {
package rpdb import ( "container/list" "sync" "time" "github.com/wandoulabs/redis-port/pkg/libs/errors" "github.com/wandoulabs/redis-port/pkg/libs/log" "github.com/wandoulabs/redis-port/pkg/rdb" "github.com/wandoulabs/rpdb/pkg/store" ) var ( ErrSnapClosed = errors.Static("rpdb snapshot has been closed") ) type RpdbSnapshot struct { mu sync.Mutex sp store.Snapshot cursor struct { it store.Iterator sync.Mutex } readers struct { list.List sync.Mutex } }
// Licensed under the MIT (MIT-LICENSE.txt) license. package rpdb import ( "bytes" "encoding/binary" "math" "github.com/wandoulabs/redis-port/pkg/libs/bytesize" "github.com/wandoulabs/redis-port/pkg/libs/errors" "github.com/wandoulabs/redis-port/pkg/libs/io/ioutils" ) var ( ErrVarbytesLen = errors.Static("invalid varbytes length") ) const ( maxVarbytesLen = bytesize.MB * 512 ) type BufReader struct { r *bytes.Reader } func NewBufReader(p []byte) *BufReader { return &BufReader{bytes.NewReader(p)} } func (r *BufReader) ReadByte() (byte, error) {