<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def managed(name,
            value=None,
            host=DEFAULT_HOST,
            port=DEFAULT_PORT,
            time=DEFAULT_TIME,
            min_compress_len=DEFAULT_MIN_COMPRESS_LEN):
    '''
    Manage a memcached key.

    name
        The key to manage

    value
        The value to set for that key

    host
        The memcached server IP address

    port
        The memcached server port


    .. code-block:: yaml

        foo:
          memcached.managed:
            - value: bar
    '''
    ret = {'name': name,
           'changes': {},
           'result': False,
           'comment': ''}

    try:
        cur = __salt__['memcached.get'](name, host, port)
    except CommandExecutionError as exc:
        ret['comment'] = six.text_type(exc)
        return ret

    if cur == value:
        ret['result'] = True
        ret['comment'] = 'Key \'{0}\' does not need to be updated'.format(name)
        return ret

    if __opts__['test']:
        ret['result'] = None
        if cur is None:
            ret['comment'] = 'Key \'{0}\' would be added'.format(name)
        else:
            ret['comment'] = 'Value of key \'{0}\' would be changed'.format(name)
        return ret

    try:
        ret['result'] = __salt__['memcached.set'](
            name, value, host, port, time, min_compress_len
        )
    except (CommandExecutionError, SaltInvocationError) as exc:
        ret['comment'] = six.text_type(exc)
    else:
        if ret['result']:
            ret['comment'] = 'Successfully set key \'{0}\''.format(name)
            if cur is not None:
                ret['changes'] = {'old': cur, 'new': value}
            else:
                ret['changes'] = {'key added': name, 'value': value}
        else:
            ret['comment'] = 'Failed to set key \'{0}\''.format(name)
    return ret