Exemplo n.º 1
0
// 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.")
}
Exemplo n.º 2
0
// 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.")
}
Exemplo n.º 3
0
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
}
Exemplo n.º 4
0
func (cq *InCommandQueue) setcounter(obj *storage.MetaDataUpdObj) {
	cq.keystorage.SetCounter(obj.MetaDataCounter())
}
Exemplo n.º 5
0
func (cq *InCommandQueue) put(obj *storage.MetaDataUpdObj) {
	cq.keystorage.Put(obj.MetaDataObj())
}