private function getBufferLength($thrift): int
    {
        $memoryBuffer = new TMemoryBuffer();

        $thrift->write(new TCompactProtocol($memoryBuffer));

        return $memoryBuffer->available();
    }