'Internal wrapper for incr/decr.'

def _incrdecr(self, cmd, key, val):

    if self._disconnected:
        return fail(RuntimeError('not    connected'))
    if (not isinstance(key, bytes)):
        return fail(ClientError(('Invalid    type    for    key:    %s,    expecting    bytes' % (type(key),))))
    if (len(key) > self.MAX_KEY_LENGTH):
        return fail(ClientError('Key    too    long'))
    fullcmd = '    '.join([cmd, key, intToBytes(int(val))])
    self.sendLine(fullcmd)
    cmdObj = Command(cmd, key=key)
    self._current.append(cmdObj)
    return cmdObj._deferred
