MCPcopy Create free account
hub / github.com/dadgar/onecache / Add

Method Add

onecache/onecache_rpc.go:176–189  ·  view source on GitHub ↗

Add adds a key only if it doesn't currently exist.

(args StorageArgs, resp *struct{})

Source from the content-addressed store, hash-verified

174
175// Add adds a key only if it doesn't currently exist.
176func (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.
192func (r *rpcServer) Replace(args StorageArgs, resp *struct{}) error {

Callers 6

convertMemcacheExpToUnixFunction · 0.45
runMethod · 0.45
addMethod · 0.45
replicateBackfillMethod · 0.45
TestMarkTouchedFunction · 0.45
TestTouchRemoteFunction · 0.45

Calls 4

targetNodeMethod · 0.95
forwardMethod · 0.95
markClientVersionMethod · 0.95
MarkDirtyMethod · 0.65

Tested by 2

TestMarkTouchedFunction · 0.36
TestTouchRemoteFunction · 0.36