<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def terms_updated(sender, **kwargs):
 """Called when terms and conditions is changed - to force cache clearing"""

    LOGGER.debug("T&C Updated Signal Handler")
    cache.delete('tandc.active_terms_ids')
    cache.delete('tandc.active_terms_list')
    if kwargs.get('instance').slug:
        cache.delete('tandc.active_terms_' + kwargs.get('instance').slug)
    for utandc in UserTermsAndConditions.objects.all():
        cache.delete('tandc.not_agreed_terms_' + utandc.user.get_username())