MCPcopy Create free account
hub / github.com/Tencent/phxqueue / Put

Method Put

phxqueue/lock/lockdb.cpp:323–353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

321//}
322
323comm::RetCode LockDb::Put(const string &k, const proto::LocalLockInfo &v, const bool sync) {
324 if (0 >= k.size()) {
325 QLErr("key \"%s\" invalid", k.c_str());
326
327 return comm::RetCode::RET_ERR_KEY;
328 }
329
330 if (Type::MAP == type_) {
331 // TODO: emplace?
332 map_[k] = v;
333 QLVerb("key \"%s\" ver %llu", k.c_str(), v.version());
334 } else if (Type::LEVELDB == type_) {
335 string vstr;
336 // TODO: Not copy?
337 proto::LocalLockInfo v2 = v;
338 v2.clear_expire_time_ms();
339 bool succ{v2.SerializeToString(&vstr)};
340 if (!succ) {
341 QLErr("SerializeToString err");
342
343 return comm::RetCode::RET_ERR_LOGIC;
344 }
345 QLVerb("key \"%s\" ver %llu", k.c_str(), v.version());
346
347 return Put(k, vstr, sync);
348 } else {
349 return comm::RetCode::RET_ERR_NO_IMPL;
350 }
351
352 return comm::RetCode::RET_OK;
353}
354
355comm::RetCode LockDb::Put(const string &k, const string &vstr, const bool sync) {
356 if (0 >= k.size()) {

Callers 9

ProtoGetAddrScaleMethod · 0.45
ProtoAddMethod · 0.45
ProtoGetMethod · 0.45
ProtoGetLockInfoMethod · 0.45
ProtoAcquireLockMethod · 0.45
WaitMethod · 0.45
InitMethod · 0.45
WriteCheckpointMethod · 0.45

Calls 1

ToStringMethod · 0.80

Tested by

no test coverage detected