Ejemplo n.º 1
0
func (self *God) get(o Operation, r *Response) {
	if !self.okArity(o, 1, r) {
		return
	}
	key := gotomic.StringKey(o.Parameters[0])
	hash, hc := self.shard(key)
	if t, ok := hash.GetHC(hc, key); ok {
		r.Result = OK | EXISTS
		r.Parts = []string{t.(string)}
		return
	}
	r.Result = OK | MISSING
	r.Parts = nil
}
Ejemplo n.º 2
0
func (self *God) del(o Operation, r *Response) {
	if !self.okArity(o, 1, r) {
		return
	}
	self.log(o)
	key := gotomic.StringKey(o.Parameters[0])
	hash, hc := self.shard(key)
	if t, ok := hash.DeleteHC(hc, key); ok {
		r.Result = OK | EXISTS
		r.Parts = []string{t.(string)}
	} else {
		r.Result = OK | MISSING
		r.Parts = []string{""}
	}
}