def testResultCode(self): self.assertTrue(MemcacheResult.get('STORED') == MemcacheResult.get('STORED')) self.assertEquals('blaataap', MemcacheResult.get('CLIENT_ERROR blaataap').msg) self.assertEquals('blaataap', MemcacheResult.get('SERVER_ERROR blaataap').msg) self.assertTrue(MemcacheResult.get('CLIENT_ERROR blaataap') == MemcacheResult.get('CLIENT_ERROR blaataap')) self.assertEquals("MemcacheResult.STORED", repr(MemcacheResult.STORED)) try: MemcacheResult.get('XXX') self.fail() except MemcacheError: pass
def testResultCode(self): self.assertTrue( MemcacheResult.get('STORED') == MemcacheResult.get('STORED')) self.assertEquals('blaataap', MemcacheResult.get('CLIENT_ERROR blaataap').msg) self.assertEquals('blaataap', MemcacheResult.get('SERVER_ERROR blaataap').msg) self.assertTrue( MemcacheResult.get('CLIENT_ERROR blaataap') == MemcacheResult.get( 'CLIENT_ERROR blaataap')) self.assertEquals("MemcacheResult.STORED", repr(MemcacheResult.STORED)) try: MemcacheResult.get('XXX') self.fail() except MemcacheError: pass
def read_get(self, reader, with_cas_unique = False): result = {} while True: response_line = reader.read_line() if response_line.startswith('VALUE'): response_fields = response_line.split(' ') key = response_fields[1] flags = int(response_fields[2]) n = int(response_fields[3]) if with_cas_unique: cas_unique = int(response_fields[4]) encoded_value = reader.read_bytes(n) reader.read_line() #\r\n if with_cas_unique: result[key] = (self._codec.decode(flags, encoded_value), cas_unique) else: result[key] = self._codec.decode(flags, encoded_value) elif response_line == 'END': return MemcacheResult.OK, result else: return MemcacheResult.get(response_line), {}
def read_get(self, reader, with_cas_unique=False): result = {} while True: response_line = reader.read_line() if response_line.startswith('VALUE'): response_fields = response_line.split(' ') key = response_fields[1] flags = int(response_fields[2]) n = int(response_fields[3]) if with_cas_unique: cas_unique = int(response_fields[4]) encoded_value = reader.read_bytes(n) reader.read_line() #\r\n if with_cas_unique: result[key] = (self._codec.decode(flags, encoded_value), cas_unique) else: result[key] = self._codec.decode(flags, encoded_value) elif response_line == 'END': return MemcacheResult.OK, result else: return MemcacheResult.get(response_line), {}
def _read_incdec(self, reader): response_line = reader.read_line() try: return MemcacheResult.OK, int(response_line) except ValueError: return MemcacheResult.get(response_line), None
def read_version(self, reader): response_line = reader.read_line() if response_line.startswith('VERSION'): return MemcacheResult.OK, response_line[8:].strip() else: return MemcacheResult.get(response_line), None
def _read_result(self, reader, value = None): response_line = reader.read_line() return MemcacheResult.get(response_line), value
def _read_result(self, reader, value=None): response_line = reader.read_line() return MemcacheResult.get(response_line), value