Add adds a key only if it doesn't currently exist.
(args StorageArgs, resp *struct{})
| 174 | |
| 175 | // Add adds a key only if it doesn't currently exist. |
| 176 | func (r *rpcServer) Add(args StorageArgs, resp *struct{}) error { |
| 177 | target := r.targetNode(args.Key, args.ExplicitPeer) |
| 178 | if target != r.n.name { |
| 179 | return r.forward(target, "Node.Add", args, resp) |
| 180 | } |
| 181 | |
| 182 | if err := r.n.data.Add(args.Key, args.Value, args.Exp, args.Flags); err != nil { |
| 183 | return err |
| 184 | } |
| 185 | |
| 186 | r.n.replicator.MarkDirty(args.Key) |
| 187 | r.markClientVersion(args.Key) |
| 188 | return nil |
| 189 | } |
| 190 | |
| 191 | // Replace sets the content of a key only if it exists. |
| 192 | func (r *rpcServer) Replace(args StorageArgs, resp *struct{}) error { |