예제 #1
0
파일: inmemory.go 프로젝트: maxzerbini/ovo
// Change the key of an item.
func (ks *InMemoryStorage) UpdateKey(obj *storage.MetaDataUpdObj) error {
	if obj != nil {
		if len(obj.Key) == 0 {
			return errors.New("Object key is null.")
		}
		if len(obj.NewKey) == 0 {
			return errors.New("Object new key is null.")
		}
		if len(obj.Collection) == 0 {
			obj.Collection = "default"
		}
		obj.CreationDate = time.Now()
		ks.collection.UpdateKey(obj)
		return nil
	}
	return errors.New("Object is null.")
}
예제 #2
0
파일: inmemory.go 프로젝트: maxzerbini/ovo
// Update an item if the value is not changed.
func (ks *InMemoryStorage) UpdateValueIfEqual(obj *storage.MetaDataUpdObj) error {
	if obj != nil {
		if len(obj.Key) == 0 {
			return errors.New("Object key is null.")
		}
		if len(obj.Collection) == 0 {
			obj.Collection = "default"
		}
		obj.CreationDate = time.Now()
		if ks.collection.UpdateValueIfEqual(obj) {
			return nil
		} else {
			return errors.New("Objects are not equal.")
		}
	}
	return errors.New("Object is null.")
}
예제 #3
0
파일: model.go 프로젝트: maxzerbini/ovo
func NewMetaDataUpdObj(req *OvoKVUpdateRequest) *storage.MetaDataUpdObj {
	var obj = new(storage.MetaDataUpdObj)
	obj.Key = req.Key
	obj.NewKey = req.NewKey
	obj.Data = req.Data
	obj.NewData = req.NewData
	obj.Hash = req.Hash
	obj.NewHash = req.NewHash
	return obj
}
예제 #4
0
func (cq *InCommandQueue) setcounter(obj *storage.MetaDataUpdObj) {
	cq.keystorage.SetCounter(obj.MetaDataCounter())
}
예제 #5
0
func (cq *InCommandQueue) put(obj *storage.MetaDataUpdObj) {
	cq.keystorage.Put(obj.MetaDataObj())
}