示例#1
0
func (b *Bucket) MutateIn(key string, cas Cas, expiry uint32) *MutateInBuilder {
	return &MutateInBuilder{
		bucket: b,
		name:   key,
		cas:    gocbcore.Cas(cas),
		expiry: expiry,
	}
}
示例#2
0
文件: bucket_crud.go 项目: avsej/gocb
func (b *Bucket) replace(key string, value interface{}, cas Cas, expiry uint32) (Cas, MutationToken, error) {
	bytes, flags, err := b.transcoder.Encode(value)
	if err != nil {
		return 0, MutationToken{}, err
	}

	return b.hlpCasExec(func(cb ioCasCallback) (pendingOp, error) {
		op, err := b.client.Replace([]byte(key), bytes, flags, gocbcore.Cas(cas), expiry, gocbcore.StoreCallback(cb))
		return op, err
	})
}
示例#3
0
func (item *RemoveOp) execute(b *Bucket, signal chan BulkOp) {
	op, err := b.client.Remove([]byte(item.Key), gocbcore.Cas(item.Cas),
		func(cas gocbcore.Cas, mutToken gocbcore.MutationToken, err error) {
			item.Err = err
			if item.Err == nil {
				item.Cas = Cas(cas)
			}
			signal <- item
		})
	if err != nil {
		item.Err = err
		signal <- item
	} else {
		item.bulkOp.pendop = op
	}
}
示例#4
0
func (item *ReplaceOp) execute(b *Bucket, signal chan BulkOp) {
	bytes, flags, err := b.transcoder.Encode(item.Value)
	if err != nil {
		item.Err = err
		signal <- item
	} else {
		op, err := b.client.Replace([]byte(item.Key), bytes, flags, gocbcore.Cas(item.Cas), item.Expiry,
			func(cas gocbcore.Cas, mutToken gocbcore.MutationToken, err error) {
				item.Err = err
				if item.Err == nil {
					item.Cas = Cas(cas)
				}
				signal <- item
			})
		if err != nil {
			item.Err = err
			signal <- item
		} else {
			item.bulkOp.pendop = op
		}
	}
}
示例#5
0
文件: bucket_crud.go 项目: avsej/gocb
func (b *Bucket) remove(key string, cas Cas) (Cas, MutationToken, error) {
	return b.hlpCasExec(func(cb ioCasCallback) (pendingOp, error) {
		op, err := b.client.Remove([]byte(key), gocbcore.Cas(cas), gocbcore.RemoveCallback(cb))
		return op, err
	})
}
示例#6
0
文件: bucket_crud.go 项目: avsej/gocb
func (b *Bucket) touch(key string, cas Cas, expiry uint32) (Cas, MutationToken, error) {
	return b.hlpCasExec(func(cb ioCasCallback) (pendingOp, error) {
		op, err := b.client.Touch([]byte(key), gocbcore.Cas(cas), expiry, gocbcore.TouchCallback(cb))
		return op, err
	})
}