func (coll *InMemoryCollection) UpdateKeyAndValueIfEqual(obj *storage.MetaDataUpdObj) bool {
	retChan := make(chan bool)
	defer close(retChan)
	coll.commands <- func() {
		if ret, ok := coll.storage[obj.Key]; ok {
			if bytes.Equal(ret.Data, obj.Data) {
				delete(coll.storage, obj.Key)
				ret.Data = obj.NewData
				ret.Key = obj.NewKey
				ret.Hash = obj.NewHash
				ret.CreationDate = obj.CreationDate
				coll.storage[obj.NewKey] = ret
				retChan <- true
			} else {
				retChan <- false
			}
		} else {
			retChan <- false
		}
	}
	return <-retChan  
}
Update an item (key and value) if the value is not changed.
package inmemory
import (
	"bytes"
	"time"
	"github.com/maxzerbini/ovo/storage"
)
type InMemoryCollection struct {
	storage  map[string]*storage.MetaDataObj
	counters map[string]*storage.MetaDataCounter
	commands chan func()
}
func (coll *InMemoryCollection) execCmd() {
	for f := range coll.commands {
		f()
	}
}
func NewCollection() *InMemoryCollection {
	coll := new(InMemoryCollection)
	coll.storage = make(map[string]*storage.MetaDataObj, 10)
	coll.counters = make(map[string]*storage.MetaDataCounter, 10)
	coll.commands = make(chan func(), collection_buffer_size)
	go coll.execCmd()
	return coll
}
func (coll *InMemoryCollection) Put(obj *storage.MetaDataObj) {
	coll.commands <- func() { coll.storage[obj.Key] = obj }
}
func (coll *InMemoryCollection) Get(key string) (*storage.MetaDataObj, bool) {
	retChan := make(chan *storage.MetaDataObj)
	defer close(retChan)
	coll.commands <- func() {
		if ret, ok := coll.storage[key]; ok {
			retChan <- ret
		} else {
			retChan <- nil
		}
	}
	var result = <-retChan
	if result == nil {
		return nil, false
	} else {
		return result, true
	}
}
func (coll *InMemoryCollection) Delete(key string) {
	coll.commands <- func() { delete(coll.storage, key) }
}
func (coll *InMemoryCollection) DeleteExpired(key string) {
	coll.commands <- func() {
		if ret, ok := coll.storage[key]; ok {
			if ret.IsExpired() {
				delete(coll.storage, key)
			}
		}
	}
}
func (coll *InMemoryCollection) GetAndRemove(key string) (*storage.MetaDataObj, bool) {
	retChan := make(chan *storage.MetaDataObj)
	defer close(retChan)
	coll.commands <- func() {
		if ret, ok := coll.storage[key]; ok {
			delete(coll.storage, key)
			retChan <- ret
		} else {
			retChan <- nil
		}
	}
	var result = <-retChan
	if result == nil {
		return nil, false
	} else {
		return result, true
	}
}
func (coll *InMemoryCollection) UpdateValueIfEqual(obj *storage.MetaDataUpdObj) bool {
	retChan := make(chan bool)
	defer close(retChan)
	coll.commands <- func() {
		if ret, ok := coll.storage[obj.Key]; ok {
			if bytes.Equal(ret.Data, obj.Data) {
				ret.Data = obj.NewData
				ret.CreationDate = obj.CreationDate
				retChan <- true
			} else {
				retChan <- false  
			}
		} else {
			retChan <- false  
		}
	}
	return <-retChan  
}