MCPcopy Create free account
hub / github.com/acl-dev/acl / get_data

Method get_data

lib_acl_cpp/src/memcache/memcache.cpp:383–416  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

381}
382
383int memcache::get_data(void* buf, size_t size)
384{
385 acl_assert(content_length_ >= length_);
386
387 if (length_ == content_length_) {
388 // ��ȡ����β���� "\r\n"
389 if (!conn_->gets(res_line_)) {
390 close();
391 ebuf_.format("read data CRLF error");
392 return -1;
393 }
394 // ��ȡ "END\r\n"
395 if (!conn_->gets(res_line_)
396 || res_line_.compare("END", false) != 0) {
397
398 close();
399 ebuf_.format("END flag not found");
400 return -1;
401 }
402 return 0;
403 }
404
405 size_t n = content_length_ - length_;
406 if (n > size) {
407 n = size;
408 }
409 if (conn_->read(buf, n) < 0) {
410 close();
411 ebuf_.format("read data error!");
412 return -1;
413 }
414 length_ += n;
415 return (int) n;
416}
417
418bool memcache::get(const char* key, size_t klen, string& out,
419 unsigned short* flags)

Callers 2

server_pool2_runFunction · 0.45
server_pool_runFunction · 0.45

Calls 5

getsMethod · 0.80
compareMethod · 0.80
closeFunction · 0.50
formatMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected