Exemple #1
0
func NewMetaDataObj(req *OvoKVRequest) *storage.MetaDataObj {
	var obj = new(storage.MetaDataObj)
	obj.Key = req.Key
	obj.Data = req.Data
	obj.Collection = req.Collection
	obj.TTL = req.TTL
	obj.Hash = req.Hash
	return obj
}
Exemple #2
0
// Add an item to the storage.
func (ks *InMemoryStorage) Put(obj *storage.MetaDataObj) 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()
		ks.collection.Put(obj)
		if obj.TTL > 0 {
			go ks.cleaner.AddElement(obj)
		}
	}
	return errors.New("Object is null.")
}