Пример #1
0
    def read_get(self, reader, with_cas_unique = False):
        result = {}

        while True:
            response_line = reader.read_bytes_available()
            header = self._unpack_header(response_line[:24])
            mem_result = MemcacheBinResult.get(header['status'])

            if mem_result == MemcacheResult.OK:
                key_begin = MemcacheBinaryProtocol.HEADER_LENGTH + header['extra_length']
                key_end = key_begin + header['key_length']
                key = response_line[key_begin:key_end]
                value = response_line[key_end:]
                result[key] = value
                return MemcacheResult.OK, result
            elif mem_result == MemcacheResult.NOT_FOUND:
                return MemcacheBinResult.OK, {}
Пример #2
0
    def read_stats(self, reader):
        result = {}

        while True:
            response_line = reader.read_bytes_available()
            header = self._unpack_header(response_line[:24])
            mem_result = MemcacheBinResult.get(header['status'])
            
            if mem_result == MemcacheResult.OK:
                key_begin = MemcacheBinaryProtocol.HEADER_LENGTH + header['extra_length']
                key_end = key_begin + header['key_length']
                val_end = key_end + header['total_body'] - header['key_length']
                key = response_line[key_begin:key_end]
                value = response_line[key_end:val_end]
                result[key] = value
                return MemcacheResult.OK, result
            else:
                return MemcacheBinResult.ERROR, {}
Пример #3
0
 def _read_result(self, reader, value = None):
     response_line = reader.read_bytes_available()
     header = self._unpack_header(response_line[:24])
     return MemcacheBinResult.get(header['status']), value