This will cache the contents of a template fragment for a given amount
    of time with support tags.

    Usage::
        {% tcache [expire_time] [fragment_name] [tags='tag1,tag2'] %}
            .. some expensive processing ..
        {% endtcache %}

    This tag also supports varying by a list of arguments:
        {% tcache [expire_time] [fragment_name] [var1] [var2] .. [tags=tags] %}
            .. some expensive processing ..
        {% endtcache %}

    Each unique set of arguments will result in a unique cache entry.

def tcache(parser, token):
    """
    This will cache the contents of a template fragment for a given amount
    of time with support tags.

    Usage::
        {% tcache [expire_time] [fragment_name] [tags='tag1,tag2'] %}
            .. some expensive processing ..
        {% endtcache %}

    This tag also supports varying by a list of arguments:
        {% tcache [expire_time] [fragment_name] [var1] [var2] .. [tags=tags] %}
            .. some expensive processing ..
        {% endtcache %}

    Each unique set of arguments will result in a unique cache entry.
    """
    nodelist = parser.parse(('endtcache',))
    parser.delete_first_token()
    tokens = token.split_contents()
    if len(tokens) < 3:
        raise template.TemplateSyntaxError("'%r' tag requires at least 2 arguments." % tokens[0])
    tags = None
    if len(tokens) > 3 and 'tags=' in tokens[-1]:
        tags = parser.compile_filter(tokens[-1][5:])
        del tokens[-1]
    return CacheNode(nodelist,
        parser.compile_filter(tokens[1]),
        tokens[2],  # fragment_name can't be a variable.
        [parser.compile_filter(token) for token in tokens[3:]],
        tags
    )