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

Method xinfo_stream

lib_acl_cpp/src/redis/redis_stream.cpp:1628–1704  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1626}
1627
1628bool redis_stream::xinfo_stream(const char* key, redis_stream_info& info)
1629{
1630 const char* argv[3];
1631 size_t lens[3];
1632
1633 argv[0] = "XINFO";
1634 lens[0] = sizeof("XINFO") - 1;
1635 argv[1] = "STREAM";
1636 lens[1] = sizeof("STREAM") - 1;
1637 argv[2] = key;
1638 lens[2] = strlen(key);
1639
1640 hash_slot(key);
1641 build_request(3, argv, lens);
1642 const redis_result* rr = run();
1643 if (rr == NULL || rr->get_type() != REDIS_RESULT_ARRAY) {
1644 return false;
1645 }
1646
1647 size_t size;
1648 const redis_result** children = rr->get_children(&size);
1649 if (children == NULL || size == 0) {
1650 return false;
1651 }
1652
1653 if (size % 2 != 0) {
1654 return false;
1655 }
1656
1657 for (size_t i = 0; i < size;) {
1658 const redis_result* first = children[i++];
1659 if (first->get_type() != REDIS_RESULT_STRING) {
1660 i++;
1661 continue;
1662 }
1663
1664 string name, value;
1665 size_t n = 0;
1666
1667 const redis_result* second = children[i++];
1668 redis_result_t type = second->get_type();
1669 if (type == REDIS_RESULT_STRING) {
1670 second->argv_to_string(value);
1671 if (value.empty()) {
1672 continue;
1673 }
1674 } else if (type == REDIS_RESULT_INTEGER) {
1675 bool ok;
1676 n = (size_t) second->get_integer(&ok);
1677 if (!ok) {
1678 continue;
1679 }
1680 } else if (type != REDIS_RESULT_ARRAY) {
1681 continue;
1682 }
1683
1684 first->argv_to_string(name);
1685

Callers 1

xinfo_streamFunction · 0.80

Calls 8

hash_slotFunction · 0.85
build_requestFunction · 0.50
runFunction · 0.50
get_typeMethod · 0.45
get_childrenMethod · 0.45
argv_to_stringMethod · 0.45
emptyMethod · 0.45
get_integerMethod · 0.45

Tested by

no test coverage detected