// 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.") }
// 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.") }
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 }
func (cq *InCommandQueue) setcounter(obj *storage.MetaDataUpdObj) { cq.keystorage.SetCounter(obj.MetaDataCounter()) }
func (cq *InCommandQueue) put(obj *storage.MetaDataUpdObj) { cq.keystorage.Put(obj.MetaDataObj()) }